A pattern for triggering many async queries

If you are triggering a lot of queries in succession then the normal trigger.onSuccess pattern get very messy. In these case it is best to use an async pattern like so.

if (txtAddTemplateName.value) { // Only execute if form is filled in - Form validation of sorts
(async () => {
  const sourceid = tblSource.selectedRow.data.sourceid // Set variables
  let data1 = await qrySourceUpdate.trigger() 					       const myField = qrySourceUpdate.data.theField[0]
  let data2 = await jsSetView.trigger({additionalScope: {skipSelect: true}})	
if (data2) {
     const myField = data2.theField[0]
     return myField
   } else {
     throw new Error("Query returned no data!")
   }	
  await new Promise(resolve => setTimeout(resolve, 1000))
  await jsSetSourceSelection.trigger({additionalScope: {sourceid: sourceid, assumeSameID: true}})  // Select the updated row if needed
  await jsSourceRowSelect.trigger()  // trigger subtable setups
 })();
}

(from @bradlymathews)