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

Add 3 days to script for "Test"

Avatar

Avatar
Validate 1
Level 1
drewettj
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
drewettj
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
drewettj
Level 1

06-04-2021

Hello in an adobe campaign classic workflow I am using a "Test" node (the yellow diamond) to check that another workflow "TECHNICALWORKFLOW" has run today before proceeding. This is working well currently with the following script: 

 

formatDate(getOption("lastRunDate_TECHNICALWORKFLOW"),'%2D-%2M-%4Y') == formatDate(getCurrentDate(),'%2D-%2M-%4Y')

 

I would like to make it so that the test instead, looks to check the TECHNICALWORKFLOW has run any time in the past 3 days, rather than today. I think I need to add +3 days somewhere to the second half of the script, but cannot work it out. 

 

Thanks 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 3
Level 3
Amit_Shinde
Level 3

Likes

22 likes

Total Posts

17 posts

Correct Reply

11 solutions
Top badges earned
Boost 3
Boost 1
Affirm 3
Affirm 1
View profile

Avatar
Boost 3
Level 3
Amit_Shinde
Level 3

Likes

22 likes

Total Posts

17 posts

Correct Reply

11 solutions
Top badges earned
Boost 3
Boost 1
Affirm 3
Affirm 1
View profile
Amit_Shinde
Level 3

06-04-2021

Hi,

 

Add the below script in the Test activity advanced tab.

 

var date = getCurrentDate();
date.setDate(date.getDate()-3);
vars.currminus3Date = formatDate(date,'%2D-%2M-%4Y');

 

After that use the below condition in the test activity

formatDate(getOption("lastRunDate_TECHNICALWORKFLOW"),'%2D-%2M-%4Y') >= vars.currminus3Date

 

Attaching the screenshot also. Hope this helps.

Amit694_0-1617770201963.pngAmit694_1-1617770223405.png

 

 

Answers (1)

Answers (1)

Avatar

Avatar
Validate 1
MVP
Darren_Bowers
MVP

Likes

78 likes

Total Posts

263 posts

Correct Reply

84 solutions
Top badges earned
Validate 1
Affirm 50
Establish
Give Back 3
Applaud 25
View profile

Avatar
Validate 1
MVP
Darren_Bowers
MVP

Likes

78 likes

Total Posts

263 posts

Correct Reply

84 solutions
Top badges earned
Validate 1
Affirm 50
Establish
Give Back 3
Applaud 25
View profile
Darren_Bowers
MVP

06-04-2021

Hi @drewettj - an easy way to do this is to subtract the last run time from the current time and see if its less than 3 days. e.g.

 

(getCurrentDate().getTime() - getOption("lastRunDate_TECHNICALWORKFLOW").getTime())<=259200000

 

Date.getTime() returns milliseconds for for 3 days = (3 * 1000 * 60 * 60 * 24) = 259200000 milliseconds

Cheers

darren