title: Custom Formula in Condition Format Rule Builder Script
body: <p>I have a custom formula that I've been using within the conditional formatting rules. However I am trying to write a script that builds the rules automatically on open so that they 'reset' to the correct order (the ranges get messed up when rearranging cells) The code I currently have is:</p>
  
  <pre><code>function onOpen() {
    var sheet = SpreadsheetApp.getActiveSheet();
    var range = sheet.getRange("C1:D600");
  
    var rule = SpreadsheetApp.newConditionalFormatRule()
                             .whenFormulaSatisfied(=$E1="x")
                             .setBackground("red")
                             .setRanges([range])
                             .build();
  
    var rules = sheet.getConditionalFormatRules();
  
    rules.push(rule);
    sheet.setConditionalFormatRules(rules);
  }
  </code></pre>
  
  <p>In the conditional formatting menu I have it set to Custom Formula Is... =$E1="x"</p>
  
  <p>How can I get that formula to work within the script conditional format rule builder? I get syntax errors for it currently.</p>