I would like to ad the current time (system time) plus 4 week in a field, do I need to create this as an Expression or SQL query? what function should one use, what function do I need to add 4 weeks to the system time?
I used “SELECT SYSTIMESTAMP FROM dual” as a first step, unfortunately I got an error.
regards,
Page 1 / 1
Hi @akrageb,
I would use a process enrichment workflow to achieve this. I have expiration date workflows that auto generate an expiration data using javascript by adding 30 days to the creation date. You could do +120 instead of +30, like I am doing.
Are you familiar with workflows? I can send the code over to help you if you are.
Thanks, Bryan
The code that you’d be putting into a Script task in your workflow would look something like this.
// Create Variable and new date. var expDate = new Date(); // add 30 days. expDate.setDate(expDate.getDate() + 120); // convert it to JSON format and substring to get YYYY-MM-DD. expDate = expDate.toJSON().substring(0,10); // assign to variable and make sure the it's a string. execution.setVariable('ExpirationDate',expDate.toString());
You’d have to create a process enrichment task to create the ‘expiration date’ variable, have the script task with the code about in it, and after that, an update projection task for your entity and pass in the new expiration date along with it’s identifier.
Here is how it should look:
I hope this helps! Bryan
The code that you’d be putting into a Script task in your workflow would look something like this.
// Create Variable and new date. var expDate = new Date(); // add 30 days. expDate.setDate(expDate.getDate() + 120); // convert it to JSON format and substring to get YYYY-MM-DD. expDate = expDate.toJSON().substring(0,10); // assign to variable and make sure the it's a string. execution.setVariable('ExpirationDate',expDate.toString());
You’d have to create a process enrichment task to create the ‘expiration date’ variable, have the script task with the code about in it, and after that, an update projection task for your entity and pass in the new expiration date along with it’s identifier.
Here is how it should look:
I hope this helps! Bryan
Hr Bryan,
Many thanks for your effort. Unfortunately I’m totally newbie to IFS. Can you please explain how to use enrichment workflow? where to add the JavaScript code?
Hi @akrageb,
No worries, I was pretty new to IFS a couple months ago. In order to set up a workflow, you need to create one first. There’s some IFS technical documentation on the subject, since it’s a bit of a process to get one working properly. Once you learn the basics of creating a workflow, you’ll need to know how to trigger one, which is done by either an event action, or a projection action. This is also important to research as your workflow will never run if you don’t trigger it off of either one of those.
You can define your workflow as process enrichment in your projection/event action. I have mine being triggered off of a projection action (I’m updating sales quotation expiration dates when they are created) like so (I recommend also using a projection action)
You can create your workflow in the workflow designer either before or after you add your projection action. Once you start to build your workflow, create a new task from the starting node, set it to “Process Enrichment task” from the wrench icon when you click on it, and you can add variables at the bottom, in which I have “ExpirationDate”.
From there, create a task off of this item, which is a script task. You define that it’s javascript above the section that says “inline script”. Below the Inline script bit, you have a section where you can throw your javascript code.
Next, create yet another task off of this, but have it be a projection task, set that to update, and pass in the values like so
Finally, add an end point like in the original diagram I sent, and deploy the workflow. From there, you can enable the projection/event action.
There’s a lot to consider when creating a workflow, so I’d suggest doing some research on the subject, but once you get the hang of it, it’s super useful.
I hope this helps!
Thanks, Bryan
thanks for everyone answered the thread and sorry for the late reaction