Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!

Is it possible to control Scheduler activity with Javascript?

Avatar

Level 2

Hello.

Is it possible to control Scheduler activity with Javascript?

 

Example: Use Javascript to get the first Monday (Javascript is prepared) and reflect them in the scheduler.

Example: Use Javascript to get business or non-business days from your company's own calendar (Javascript is prepared) and reflect them in the scheduler.

 

If Javascript condition is met, the transition will be enabled, otherwise it will be disabled.

Thank you.

5 Replies

Avatar

Community Advisor

@uz2020 

 

Actually, you don't need a scheduler activity to do this.

 

Just use the Advanced javascript activity and enable the transition. If your condition met then run the workflow else divert the transition to the end activity.

 

The advanced javascript activity config will look like this.

_Manoj_Kumar_0-1615643632137.png

 

and the workflow will look like this.

_Manoj_Kumar_1-1615643676775.png

 

Let me know if that helps.

 


     Manoj
     Find me on LinkedIn

Avatar

Level 2

@Manoj_Kumar_, Thank you for reply.

 

I understood that Advanced JS can branch judgments.
Is usage of Advanced JS correct in the following?

 

 

//First call
if(Today is first Monday and business day){
 task.postEvent(task.transitionByName("ok"));
}else{
 task.postEvent(task.transitionByName("no"));
}
task.setCompleted();

//Next call
return 0;

 

 

And, Is there no choice but to start the scheduler every day and use JS to determine the business day?

Thanks.

Avatar

Community Advisor

Hi @uz2020 

For the first case, just use the scheduler, by selecting monthly, you have first Monday option

DavidKangni_0-1615834867462.png

For your second case: if your calendar is accessible through API, you can do some api call to it and parse the response if it's a business day or not.

 

other choice instead of running permanently a scheduler is to calculate the condition from an external system and trigger the workflow with a signal.

Thanks,

David



David Kangni

Avatar

Level 2
Hello @DavidKangni, Thank you for your reply. In the first case, if the first Monday is a non-business day, it cannot be delivered on the next business day. Currently, Run the scheduler every day, run Workflow if the conditions are met in Javascript, and quit otherwise. It may correspond to the second case. Running the scheduler every day Waste seless, so I'm thinking about if I can control it. Thank you.

Avatar

Administrator

Hi @uz2020,

Were you able to resolve this query or do you still need more help here? Do let us know.

Thanks!



Sukrity Wadhwa