
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2021 07:29 AM
Hello,
I am running into an issue with the "Wait for Condition" workflow activity. I have a script which takes in a date/time catalog variable, turns it into a number of milliseconds, and then uses gs.dateDiff to compare that number with the current date/time. The script then provides the wait time, in seconds, to the "answer." I have this working in a different workflow.
Here is my problem - this particular workflow has an approval step before the wait for activity. If the approval happens after the date/time field, it returns a negative value and then never fulfills the condition. I attempted to fix this with an if/else statement, but although the activity reaches the end of the script, it does not continue the flow after waiting the offset amount of time.
Script below. Any advise is greatly appreciated!
// Set 'answer' to the number of seconds this timer should wait
//get datetime variable
var datetime = new GlideDateTime();
datetime.setDisplayValue(current.variable_pool.v_date_time.getDisplayValue());
//convert to millisecond value and add specified time
var datetimeValue = datetime.getNumericValue();
//datetimeValue += (1000*60*60*24); //Adds 1 day
//write offset time to datetime variable
var offsetDate = new GlideDateTime();
offsetDate.setNumericValue(datetimeValue);
//workflow.info("heyyyy "+gs.dateDiff(gs.nowDateTime(),offsetDate.getDisplayValue(),true)); //confirmed this is -
//write comments to RITM
if (gs.dateDiff(gs.nowDateTime(),offsetDate.getDisplayValue(),true) > 0){
current.comments = '"Additional task on hold until: ' + offsetDate.getDisplayValue();
// Set 'answer' to the number of seconds this timer should wait
answer = gs.dateDiff(gs.nowDateTime(),offsetDate.getDisplayValue(),true);
//workflow.info(answer);
}
else{
// current.comments = "made it";
answer = 10; //should wait 10 seconds?
// workflow.info(answer);
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2021 10:18 AM
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2021 10:18 AM
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2021 10:45 AM
Thanks a bunch Anil! I had myself going crazy over this and that was it. Script was good all along haha.