Sync Javascript call

Here is my javascript code sample. I want the steps to be executed in the same order. I found out that "Activity Id" has stale value in the localStorage. What's the trick to making sure that all these steps execute in the exact same order and each one waits for the last to line to complete. Appreciate.

await quickActivityCreateDB.trigger();
var activityId = quickActivityCreateDB.data['Activity Id'];
localStorage.setValue("activityId", activityId);
await findActivityDetailDB.trigger();
quickActivityPopupBtn.close();

You almost have it.

Add an await front of the setValue() line.

Then make sure that "Keep variable refrences inside the query in sync with your app" is enabled (on the Advanced tab.)

1 Like