Forum Discussion

JessicaFeauto2's avatar
JessicaFeauto2
Qrew Cadet
4 years ago

Javascript Code Page run Automations with delay between each

Hi there,

I am trying to run a section of code shared by Dan from here: Pastie

The code works great to do several procedures and eventually fire off some automations when field Id 45 is filled in.  The problem is that the automations end up all running at once; I need them to run sequentially.  I tried inserting the underlined timeout lines to put a lag between filling in each record.  The lag works, but then the records aren't filled in correctly; it seems to not be retrieving the record information properly. Any thoughts?

I am also open to other ideas to run automations with a lag!  Code is below:
$("record", xml2).each(async function(index) {

setTimeout(async function() { ////Timeout function

var record = $("record_number", this).text();
var now = $("now", this).text();


var xml3 =await Promise.resolve(
$.get(dbid1, {
act: "API_EditRecord",
rid: record,
_fid_45: now,

})
);
console.log(index);
console.dirxml(xml3);

}, count * 1000) ///Timeout function
count++; ///timeout function


});

}

------------------------------
Jessica Jessica
------------------------------

1 Reply

  • Is it possible for you to adjust the triggers of your automations so that they trigger one another in sequence, rather than using the script?

    ------------------------------
    Blake Harrison
    bharrison@datablender.io
    DataBlender - Quickbase Solution Provider
    Atlanta GA
    404.800.1702 / http://datablender.io/
    ------------------------------