Google App Script Trigger Cannot Retain Data to Be Used For The Second Trigger

I created a Google Sheet that allows a user to enter a specific ID number from a cell. The script takes that information, makes an API call, and saves the information to a variable called “invoiceItems”. It will then displays it on the sheet for the user to confirm that the information is correct. The user also has the option to send out an email if the checkbox is checked.

// Set Global Variable
let invoiceItems = {};

function main (e) {
    let invoiceData = '';  // Data from POS
    const activeSheet = SpreadsheetApp.getActiveSheet ();
    const UI = SpreadsheetApp.getUi ();
    
    // Checks if there's a change in cell E2
    if (e.range.getRow () == 2 && e.range.getColumn () == 5) {
      try {
        invoiceData = getInvoice ();
        console.log (invoiceData);
        showCustomer (invoiceData);
      }
      catch (e) {
        if (e.message.indexOf ('404') != -1) {
          UI.alert ('Error', 'No invoice found.  Check the invoice number and try again.', UI.ButtonSet.OK);
        }
      }
    }
  
  /* // Checking for the checkbox value
  if (activeSheet.getRange ("E27").getValue ()) {
    sendInvoice ();
  }
  */
    if (e.range.getRow () == 27 && e.range.getColumn () == 5 && e.value == 'TRUE') {
      sendInvoice ();
    }
  }

// Sample invoiceItems data extracted from a full list of invoiceData
invoiceItems = {
  'firstName': 'John',
  'lastName':  'Doe',
  'address_1': '555 Nowhere Street',
  'address_2':  'Sunnycity, AA 13455',
  'phone': '555-555-555',
  'email': '[email protected]'
}

The script is able to fire the trigger once the cell “E2” value has changed. The script is also able to kick off the second trigger when the send email checkbox is checked. However, the invoiceItems information isn’t present for the script to run the sendInvoice () function. I created an if statement in the sendInvoice () function to raise an error if no email is detected. This tells me that the two triggers executed independently from each other; therefore, when the second trigger kicks off, “invoiceItems” is empty.

If I don’t limit the trigger to a specific cell on the spreadsheet, the trigger works but at the expense of making 2 API calls (one for detecting changes to cell “E2” and the other when the send email checkbox is checked). Doing so will cause the script to ask the user to send the email without first displaying the information on the spreadsheet or allowing the user to verify. I could make the script sleep before asking the user to confirm sending the email but it’s not an elegant solution. Not to mention, any edit to any cell will cause a trigger.

I also tried the following but the data inside invoiceItems has some weird javascript objects in it instead of a simple string as shown in the sample data above.

// Set a property value
PropertiesService.getUserProperties().setProperty('myProperty', 'Hello, World!');

// Get a property value
function myFunction() {
  var value = PropertiesService.getUserProperties().getProperty('myProperty');
  Logger.log(value);
}

Question: Is there a way to retain the information pulled from the first trigger to be used with the second trigger?