Good morning, I'm encountering a rather unique problem that I can't seem to fix.
To make it short I use javascript code which configures schedulers, but when the workflow runs and executes the javascript code it must be restarted for the scheduler modifications to be taken into account. to prevent it from restarting the workflow in a loop I use an instance variable "<variables lastSavedDate="xxxx-xx-xx"/>". The Javascript code will check if the value that I entered in a script variable (var inputDate) is equal to instance.vars.lastSavedDate, if this is the case then it continues processing, if this is not the case then it updates the lastSavedDate variable with the value of inputDate then it restarts the workflow.
In theory I think it should work, in practice my instance variable is simply cleared. when I do a logInfo(instance.vars.lastSavedDate), the log returns "undefined" and when I return to the workflow variables there is only "<variables/>" which is entered instead of "< variables lastSavedDate="xxxx-xx-xx"/>" Do you have any idea why it does this and how to fix it?
Solved! Go to Solution.
Views
Replies
Total Likes
Hello,
I found a workaround to resolve my issue. As my script updates scheduler parameters as soon as the workflow is launched, I simply add it to the javascript code of my start activity:
activity.mask = 1;
xtk.workflow.Restart(instance.id);
This prevents the workflow from looping infinitely. If users want to change the date, they can always do so by reactivating the start activity and modifying the variable values.
I'm not sure this is a best practice but in my case it's functional
Views
Replies
Total Likes
Hi @Ragsthenos ,
Alternatively you can try the below method by creating an Option > storing the last saved date here and calling the value whenever required and updating the last saved date.
create an option (/Administration/Platform/Options/) with name as wkf1LastSavedDate
In workflow's JavaScript,
//To call last saved date time from option
vars.wkf1LastSavedDate = getOption ("wkf1LastSavedDate");
//To update the current time in the option
vars.currentTime = getCurrentDate();
setOption ("wkf1LastSavedDate", vars.currentTime);
Views
Replies
Total Likes
Unfortunately I cannot use the options because I am working on a workflow template which will be reused several times, and I therefore cannot afford to create a new option for each new workflow created from this template. Thanks for trying to help me. Is it normal for my instance variable to be deleted? I managed to display it once but when I restarted the workflow afterwards, it left me undefined.
Views
Replies
Total Likes
Hello,
I found a workaround to resolve my issue. As my script updates scheduler parameters as soon as the workflow is launched, I simply add it to the javascript code of my start activity:
activity.mask = 1;
xtk.workflow.Restart(instance.id);
This prevents the workflow from looping infinitely. If users want to change the date, they can always do so by reactivating the start activity and modifying the variable values.
I'm not sure this is a best practice but in my case it's functional
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies