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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Example of returning a promise in a custom code action?

Avatar

Community Advisor

Hi everyone, looking for some help!

 

This Adobe blog post states "If your Custom Code is JavaScript, then you can now return a promise in conditions or actions. The next condition or action will wait for the promise to resolve before executing."

 

I'm struggling to figure out how to do this.  Has anyone got a simple JavaScript code example they could share? (i.e. return a promise in an action so that the following action waits)

 

1 Accepted Solution

Avatar

Correct answer by
Level 6

Here's something you can try 

 

// action1    
return new Promise(function(resolve, reject) { setTimeout(function() { var thankGodItIsFriday = (new Date().getDay() === 5) if (thankGodItIsFriday) { resolve(); } else { reject(); } }, 1000); }); }

Editing to add article reference: 

Here's a good read around async and an example as well. 

https://www.datanalyst.info/web_analytics/adobe-launch/launch-async-sequential/

View solution in original post

1 Reply

Avatar

Correct answer by
Level 6

Here's something you can try 

 

// action1    
return new Promise(function(resolve, reject) { setTimeout(function() { var thankGodItIsFriday = (new Date().getDay() === 5) if (thankGodItIsFriday) { resolve(); } else { reject(); } }, 1000); }); }

Editing to add article reference: 

Here's a good read around async and an example as well. 

https://www.datanalyst.info/web_analytics/adobe-launch/launch-async-sequential/