Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Why not use scheduler in the middle of workflow?

MarcelSzimonisz
Community Advisor
Community Advisor

Is there any reason why not using scheduler in the middle of workflow? I am referring to scheduler set to fire at exact time only once.

https://docs.campaign.adobe.com/doc/standard/en/WKF_Execution_activities_Scheduler.html

 

Thanks 

Marcel

1 Accepted Solution
MarcelSzimonisz
Correct answer by
Community Advisor
Community Advisor

Hello Florent,

I made scheduler out of the wait by adding JS , which will parse the label and set difference between now to the wait if positive and successfully parsed. 

if (!Date.now) { Date.now = function now() { return new Date().getTime(); }; } var strDate = activity.label.split("-"); var date; //parse date from label if (Array.isArray(strDate)){ strDate = strDate[1]; date = new Date(strDate.trim()); }else logError("Date from label was not recognized."); if (isNaN(date)) logError("Date string was not recognized"); //or you can define date directly here //var date = new Date("2017/02/10 13:00:00"); var delay = date.getTime() - Date.now(); if (delay <= 0) logError("Delay is negative number"); activity.delay = Math.floor(delay / 1000);

Marcel

View solution in original post

6 Replies
florentlb
Level 10
Level 10

Hello Marcel,

The only reason I see is that as it is designed to be a 'start' activity, the Scheduler only activates its outbound transition, without passing any data. I'd suggest using a Wait activity if you need some data that were processed in the first activities of your workflow to be passed through.

Hope this helps,

Florent

florentlb
Level 10
Level 10

Hello Marcel,

Even if this is the case, Scheduler is not designed to wait for inbound data, so we cannot be sure that you won't run in any trouble with this method at some point.

Best practice with your use case would probably be to use a different workflow for each channel. Each workflow starting with a scheduler, then retrieving the targeting data using for example a Read list activity, and triggering the delivery.

Using different workflows is also a general best practice as the simpler workflows are, the easier to fix it is in case of problem or error.

Let me know how it goes for you if you still decide to keep a single workflow, that could lead to a nice example to share with the community.

Florent.

MarcelSzimonisz
Correct answer by
Community Advisor
Community Advisor

Hello Florent,

I made scheduler out of the wait by adding JS , which will parse the label and set difference between now to the wait if positive and successfully parsed. 

if (!Date.now) { Date.now = function now() { return new Date().getTime(); }; } var strDate = activity.label.split("-"); var date; //parse date from label if (Array.isArray(strDate)){ strDate = strDate[1]; date = new Date(strDate.trim()); }else logError("Date from label was not recognized."); if (isNaN(date)) logError("Date string was not recognized"); //or you can define date directly here //var date = new Date("2017/02/10 13:00:00"); var delay = date.getTime() - Date.now(); if (delay <= 0) logError("Delay is negative number"); activity.delay = Math.floor(delay / 1000);

Marcel

View solution in original post

florentlb
Level 10
Level 10

Thanks a lot for sharing that Marcel!

Florent

littlesnack
Level 1
Level 1

Hi Marcel

Thanks for sharing the JS code, but every time I ran I seem to encounter the error message as shown below:

if (!Date.now) {
Date.now = function now() {
return new Date().getTime(); };
}

var strDate = activity.label.split("-");

var date; //parse date from label

if (Array.isArray(strDate)){
strDate = strDate[1];
date = new Date(strDate.trim()); }
else
logError("Date from label was not recognized.");

if (isNaN(date))
logError("Date string was not recognized"); //or you can define date directly here //

var date = new Date("2017/07/11 13:00:00");
var delay = date.getTime() - Date.now();

if (delay <= 0)
logError("Delay is negative number");

activity.delay = Math.floor(delay / 1000);

It complains about strDate not being defined?

Could you please shed some lights on this?

Thanks

LS

guillermoL
Level 4
Level 4

Hi littlesnack,

You need to include the date you want the timer to be triggered in the label of the 'Wait' element. Something like what Marcel showed in the screenshot: Wait until - 2018/03/27 13:00:00

marcel.gent.86​ , I know you wanted it to be tolerant if the label would not hold the date, but it does complain also in my case if it's not there with the dash. Very helpful anyway, thanks.