Home > Mobile >  Assign script to run if cell data validation is "true"
Assign script to run if cell data validation is "true"

Time:08-24

What I'm trying to do is create an if statement for my code to run automatically as soon as a certain cell in the sheet has a data validation of "true" and not be assigned to a button because when I share the google sheet my users don't have access to click on the button. Unless I'm doing something wrong?

function ds631321() {
  var ss = SpreadsheetApp.getActive();
  var templateSheet = ss.getSheetByName('HUSSAR');
  var val = templateSheet.getRange('A$1').getValue();
  let result; 
    if (val = true) {
      function so5691088602() {
        const ss = SpreadsheetApp.getActive();
        const templateSheet = ss.getSheetByName('HUSSAR');
        const dateStart = templateSheet.getRange('C$2').getValue();
        const numDups = 1;
        const timezone = ss.getSpreadsheetTimeZone();
          for (let i = 1; i <= numDups; i  ) {
            const sheetName = Utilities.formatDate(dateStart, timezone, 'MMMM yyyy');
            const newSheet = ss.insertSheet(sheetName, { template: templateSheet });
            const dataRange = newSheet.getDataRange();
            dataRange.setValues(dataRange.getValues());
  }
    }
    }}

Kind Regards, Richard

CodePudding user response:

Try this:

function createTimeBasedTrigger() {
  if(ScriptApp.getProjectTriggers().filter(t => t.getHandlerFunction("ds631321")).length == 0) {
    ScriptApp.newTrigger("ds631321").timeBased().everyMinutes(15).create();
  }
}

function ds631321() {
  var ss = SpreadsheetApp.getActive();
  var templateSheet = ss.getSheetByName('HUSSAR');
  var val = templateSheet.getRange('A$1').getValue();
  let result;
  if (val = true) {
    function so5691088602() 
  }
}
  • Related