Is it possible to control Scheduler activity with Javascript? | Community
Skip to main content
Level 2
March 12, 2021
Question

Is it possible to control Scheduler activity with Javascript?

  • March 12, 2021
  • 4 replies
  • 1819 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

4 replies

_Manoj_Kumar_
Community Advisor
Community Advisor
March 13, 2021

@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.

 

and the workflow will look like this.

 

Let me know if that helps.

 

     Manoj     Find me on LinkedIn
uz2020Author
Level 2
March 15, 2021

@_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.

DavidKangni
Community Advisor
Community Advisor
March 15, 2021

Hi @uz2020 

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

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
uz2020Author
Level 2
March 16, 2021
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.
Sukrity_Wadhwa
Community Manager
Community Manager
March 24, 2021

Hi @uz2020,

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

Thanks!

Sukrity Wadhwa