Hi I believe I need to execute the following code in sequence otherwise if lists get long I may get errors because one async call may affect the other. I have two cascaded async calls. I have only ran the first lockListItems function but dubious about the reliability of running the remaining 3 functions. Currently when executed I get the following console message order : end main, List Item Loaded, end 2nd success.
Would be better to execute the next lockListItems function after console message 'end 2nd success' or does it not matter?
Is there an easy way to achieve, Promises could work but is it an overkill?
UPDATE: calling single function 'lockListItems' works but if I try to run the 2nd function after the 1st an error is reported. 'Collection not initialised'
lockListItems (ID,List1Name)
lockListItems (ID,List2Name)
lockListItems (ID,List3Name)
lockListItems (ID,List4Name)
console.log ('end main');
function lockListItems(tID,varList) {
//load items from varList where ...
executeAsync (success lockListItems, fail lockListItems)
console.log('List Item Loaded');
}
function onQuerySucceeded lockListItems(sender, args)
{
//Add required items ID to Array
UpdateStatusLocked(ArrItemsUpdate);
}
function UpdateStatusLocked(ArrItemsUpdate) {
//loop array and upade
executeAsync (success UpdateStatusLocked, fail UpdateStatusLocked
}
function onQuerySucceededUpdateStatusLocked(sender, args) {
//alert ('Updated Locked Status');
console.log('end 2nd success- List Item Completed');
}