Multiple commands in Batchplay

Good morning everybody, I’m a newbie :hugs: from Italy.and I have a question for you regarding Batchplay

. When I launch a Batchplay calling it on the same way that LAYER_CREATION-EXAMPLE does if the batchCommands constant contain only one command it’s ok but if it contains two commands only the SECOND command is excuted (yes, the second !) .could anybody explain why and suggest a way out ?



```	const batchCommands = {
     
         // FIRST COMMAND : EXECUTED EXCLUSIVELY IF IT IS THE ONLY ONE  (AKA THE SECOND COMMAND IS NON PRESENT)

         _obj: "make",
         _target: [
             {
                 _ref: "adjustmentLayer"
             }
         ],
         using: {
             _obj: "adjustmentLayer",
             type: {
                 _class: "vibrance"
             }
         },
        
         
     // SECOND COMMAND : IF THE SECOND COMMAND IS PRESENT IT WILL BE THE ONLY ONE TO BE EXECUTED (AKA THE FIRST ONE WILL NOT BE EXECUTED !!
     
         _obj: "make",
         _target: [
             {
                 _ref: "adjustmentLayer"
             }
         ],
         using: {
             _obj: "adjustmentLayer",
             type: {
                 _obj: "selectiveColor",
                 presetKind: {
                     _enum: "presetKindType",
                     _value: "presetKindDefault"
                 }
             }
         
         
         }
 
    }

Thi is the full code

 

async function createLayerFromText() {
  const mytext = document.getElementById("mytext").value;
  if (mytext.trim()) {
    const result = await makeTextLayer(mytext.trim());
    if (result[0].message) { // a message in the result means error
      showAlert(result[0].message);
    }
    else {
      const layerID = result[0].layerID;
      console.log(`after maketextLayer, id = ${layerID}`);
    }
  }
  else {
    showAlert("Please enter something in the text field first.");
  }
}

async function createLayerFromFile() {
	const fs = require("uxp").storage.localFileSystem; // always needed to access the filesystem
	const myFile = await fs.getFileForOpening({ types: ["txt"] });
    if (!myFile) {
		showAlert("No file was selected.");
        return;
	}
    const fileContents = await myFile.read();
    const result = await makeTextLayer(fileContents);
    if (result[0].message) { // a message in the result means error
      showAlert(result[0].message);
    }
 } 

async function showAlert(message) {
  	const app = require('photoshop').app;
  	await app.showAlert(message);
}

// make a text layer in the active document
// Since there's no built-in API to make a text layer (yet),
// We do it with a batchPlay call.

async function makeTextLayer(theText) {
   
   // const app = require('photoshop').app;
  // (( await app.showAlert("entrato");

  
  	const batchCommands = {
      
          // FIRST COMMAND : EXECUTED EXCLUSIVELY IF IT IS THE ONLY ONE  (AKA THE SECOND COMMAND IS NON PRESENT)

          _obj: "make",
          _target: [
              {
                  _ref: "adjustmentLayer"
              }
          ],
          using: {
              _obj: "adjustmentLayer",
              type: {
                  _class: "vibrance"
              }
          },
         
          
      // SECOND COMMAND : IF THE SECOND COMMAND IS PRESENT IT WILL BE THE ONLY ONE TO BE EXECUTED (AKA THE FIRST ONE WILL NOT BE EXECUTED !!
      
          _obj: "make",
          _target: [
              {
                  _ref: "adjustmentLayer"
              }
          ],
          using: {
              _obj: "adjustmentLayer",
              type: {
                  _obj: "selectiveColor",
                  presetKind: {
                      _enum: "presetKindType",
                      _value: "presetKindDefault"
                  }
              }
          
          
          }
  
     }
   

  	return await require("photoshop").core.executeAsModal(async () => {
  		await require('photoshop').action.batchPlay([batchCommands], {});
  	}, { commandName: "Make New Text Layer" });
}
 
 document.getElementById("btn-layer-from-text").addEventListener("click", createLayerFromText);

document.getElementById("btn-layer-from-file").addEventListener("click", createLayerFromFile);