Breaking Out Of BatchPlay

Before the BatchPlay runs, I am checking to see how many documents are open using

if(app.documents.length === 1){
      showAlert("More than Document required to use this feature.")

//batchPlay code goes here...

Now if there is only 1 document open, the Alert pops ups and stops the batchPlay from executing.

At the end of the batchplay code I use the following to workaround the focus issue


Where should this code go so that it still works if the Alert pops up because leaving it at the end of the batchplay code doesn’t appear to do anythig

I use it this way, with .then(){} after a batchplay

async function myAction() {
   await batchPlay([{
  }], {}).then(function (e) {
    // instert menu commands here
   if (e[0].message != undefined) console.log(e[0].message)

// call & show the Pop-up from here....


1 Like

Perfect @Pierre_G thank you