Skip to main content
Level 2
Mar 12, 2021 5:38 PM UTC
Question

Is it possible to control Scheduler activity with Javascript?

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.

5 replies

Manoj_Kumar
Community Advisor
Community Advisor
Mar 13, 2021 1:54 PM UTC

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

 

Translate
Manoj  | https://themartech.pro
uz2020Author
Level 2
Mar 15, 2021 1:02 PM UTC

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

Translate
DavidKangni
Adobe Champion and Community Advisor
Adobe Champion and Community Advisor
Mar 15, 2021 7:04 PM UTC

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

Translate
David Kangni
uz2020Author
Level 2
Mar 16, 2021 9:14 AM UTC
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.
Translate
Sukrity_Wadhwa
Level 4
Mar 24, 2021 11:05 AM UTC

Hi @uz2020,

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

Thanks!

Translate
Sukrity Wadhwa