Timeline for Pass value from Ampscript to SSJS Sleep function
Current License: CC BY-SA 4.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 31, 2021 at 17:28 | vote | accept | Vi Bin | ||
Aug 6, 2021 at 9:40 | comment | added | Jonas Lamberty |
Hi, that's probably because you need to make JS understand that milliseconds is an integer. 1) in AMPScript try set @ms= 6000 without double quotes. If that alone doesn't help, then in SSJS force the value to integer like var milliseconds = parseInt(Variable.GetValue("@ms")) .
|
|
Aug 6, 2021 at 8:50 | history | edited | Lukas Lunow | CC BY-SA 4.0 |
added 43 characters in body
|
Aug 6, 2021 at 8:05 | comment | added | Vi Bin |
I am not very well versed with SSJS so I am not sure if you are suggesting something like below but I tried it didnt work <script runat="server"> Platform.Load('Core','1'); var milliseconds = Variable.GetValue("@ms") function sleep(milliseconds) { var start = new Date().getTime(); for (var i = 0; i < 1e7; i++) { if ((new Date().getTime() - start) > milliseconds){ break; } } } sleep(milliseconds); </script>
|
|
Aug 6, 2021 at 7:50 | history | answered | Jonas Lamberty | CC BY-SA 4.0 |