Expand my Community achievements bar.

We are excited to introduce our latest innovation to enhance the Adobe Campaign user experience — the Adobe Campaign v8 Web User Interface!

How to use Promise in javaScript activity

Avatar

Level 2

Hello,

i want to use the following code in a javascript activity but im getting an error : 

var myPromise = new Promise(function(myResolve, myReject) {
  setTimeout(function() { myResolve("I love You !!"); }, 3000);
});

myPromise.then(function(value) {
 logInfo('Helllo Promise : '+value);
});

 

this is the error that i get :  02/04/2021 16:02:11 js7 JST-310000  ligne 2 : Promise is not defined.

 

do you have any solution please ?

Thanks in advance.

5 Replies

Avatar

Community Advisor

Hi @JamesAlio

it is not there by deafult.

You may try create a new JS library and copy code from here for example.

Finally, load library in your JS node or connector via loadLibrary("your_schema:Your_new_file.js");

 

This is not tested. If code does not work for you try with different ones (look for min.js extension)

Regards,

Milan

Avatar

Administrator

Hi @JamesAlio,

Was the given solution helpful to resolve your query or do you still need more help here? Do let us know.

Thanks!

 



Sukrity Wadhwa

Avatar

Level 2

Hello @Sukrity_Wadhwa 

no i still have the same problem. the Promise object is undefined in  my Js Activity

Avatar

Administrator
Thanks for the update. I will escalate your issue further.


Sukrity Wadhwa

Avatar

Level 4

Hi James,

I guess Promise doesn't work in Adobe Campaign. ACC Javascript implementation is Spider Monkey, so it is probably ECMAScript 5 (2009) standard. Promises were introduced with ECMA 6 (ECMAScript 2015).

Regards, Marcin