title: How to combine 2 on edit scipts in one google sheet
body: <p>I have added a link to the google sheet that I am working on.<a href="https://docs.google.com/spreadsheets/d/1MXLOvM1Wz2ZfZv-RKjdRw1TVzj16rELCIGi9-zgtMHw/edit?usp=sharing" rel="nofollow noreferrer">Copy of Automated Test ESA record sheet</a></p>
  <p>I have added this code which creates a duplicate tab of the Template sheet and renames it when the Surname and first name are input on the client information sheet (see the below script)</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function onEdit(e){
    // Global constants, ensure edit occured on the right sheet/range
    const sh = SpreadsheetApp.getActive();
    const ss = sh.getActiveSheet();
    if (ss.getName() != "Client information" || e.range.columnStart &gt; 2) return;
  
    // Set the surname and firstname variables, check that both are filled
    let sName = ss.getRange(e.range.rowStart,1).getValue();
    let fName = ss.getRange(e.range.rowStart,2).getValue();
    let name = fName + " " + sName;
    if (sName.length == 0 || fName.length == 0) return;
  
    // Create the new sheet, rename it, and set the client name on the sheet
    const template = sh.getSheetByName("TEMPLATE");
    let newSheet = template.copyTo(sh);
    newSheet.setName(name);
    newSheet.getRange(1,1).setValue(name);
    
    // Set a hyperlink from the surname on 'Client information' to the new sheet
    ss.getRange(e.range.rowStart,1).setFormula('=HYPERLINK("' + sh.getUrl() + '#gid=' + newSheet.getSheetId() + '","'+sName+'")');
  }</code></pre>
  </div>
  </div>
  </p>
  <p>I then have this code which allows me to select multiple items from a drop down in google sheets for columns L,M and N.(see the below script)</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function onEdit(e) {
    // Spreadsheet object can be retrieved from event via e.source
    var sheetName = e.source.getActiveSheet().getName();
    // Range object can be retrieved from event via e.range
    var range = e.range;
    var column = range.getColumn();
    if (sheetName == "Client information" &amp;&amp; column &gt;= 12 &amp;&amp; column &lt;= 14 &amp;&amp; e.value) {
      var newValue = e.value;
      var oldValue = e.oldValue;
      // first if statement is the default behavior, no need to include
      // the else statement is now combined on the outer if statement
      if (!e.oldValue)
        range.setValue(newValue);
      else {
        if (oldValue.indexOf(newValue) &lt; 0) 
          range.setValue(oldValue + ',' + newValue);
        else
          range.setValue(oldValue);
      }
    }
  }</code></pre>
  </div>
  </div>
  </p>
  <p>Because these are both onEdit I can't run them at the same time in this sheet as they are conflicting. I don't know how to simplify and combine them both into a single function. Can anyone please help?</p>