The CreatorCon Call for Content is officially open! Get started here.

workflow wait for condition

VivekSattanatha
Mega Sage

Hi,

Is it a best practice to use wait for condition activity for multiple days . I have a temporary server access provisioning orchestration with access start date and access end date. I can easily create a workflow with start date and end date condition using wait for condition activity. But I don't know it is a good practice? If it is not what is the impact in it.?? And how to avoid that?

Regards,

  Vivek

1 ACCEPTED SOLUTION

Hi Vivek,



You need to specify the number of seconds the workflow should wait in the answer variable. The script would go something like this


var curr_date = gs.nowDateTime(); // Used this method as it returns time in users timezone


var now = new GlideDateTime(curr_date);


var start_date = workflow.scratchpad.access_start_date;


var start= start_date + ' 00:00:00';


var eod = new GlideDateTime(start);


answer = (eod.getNumericValue() - now.getNumericValue()) / 1000;



Thanks


Thameem


View solution in original post

9 REPLIES 9

Thanks Thameem,



This is my wait for condition script.



var curr_date = new GlideDate();


var start_date = workflow.scratchpad.access_start_date;


if (start_date <= curr_date)


  {


  answer = true;


  }



can I use the same in Timer script? will it work?



Regards,


Vivek


HI Vivek



"Wait for" Condition Activity

Add the Wait for condition activity to have the workflow pause indefinitely until the current record matches a specified condition. When the current record is updated, the workflow evaluates the Wait for condition activity.



For example, in the Employee Offboarding workflow below (only part of the workflow is shown), there are two wait for condition activities. One of the activities always causes the workflow to stop until the employee's end date is reached. Another wait for condition activity always checks if all sub-tasks are inactive before moving on to the next activity.



workflow_condition_activities_waitforcondition.jpg



There is an important difference between the Wait for condition activity and the Timer activity. If you need the workflow to pause for a specific, timed duration, use the Timer activity instead of the Wait for condition activity. The Timer activity gives you greater control over how long the workflow pauses and what causes it to start again after pausing.



The Wait for condition activity can be handy if you have multiple tasks that you want completed before the workflow ends. You can configure the Wait for condition so the workflow pauses until ALL tasks are complete.





Try like   this if this will executed then then we get log updates



var curr_date = new GlideDate();


var start_date = workflow.scratchpad.access_start_date;


if (start_date <= curr_date)


  {


  answer = true;


gs.log(start_date);


gs.log(curr_date);



  }


Hi Vivek,



You need to specify the number of seconds the workflow should wait in the answer variable. The script would go something like this


var curr_date = gs.nowDateTime(); // Used this method as it returns time in users timezone


var now = new GlideDateTime(curr_date);


var start_date = workflow.scratchpad.access_start_date;


var start= start_date + ' 00:00:00';


var eod = new GlideDateTime(start);


answer = (eod.getNumericValue() - now.getNumericValue()) / 1000;



Thanks


Thameem


Hi Thameem,



Thanks for your time.



The script seems to be working fine. Where can I find the remaining waiting time in a real-time?



Regards,


Vivek


thameem1
Kilo Expert

Hi Vivek



I am not aware if we can see the real time seconds left.



Thanks


Thameem