title: SuiteScript setting "customform" in "beforeLoad"
body: <p>I am trying to set the form based on a formula in NetSuite. I want the form to use to be determine and loaded before the user accesses the page. The code I am using is a UserEventScript and it is in the beforeLoad function. determineSOForm returns the form internal id.</p>
  
  <pre><code>function beforeLoad(scriptContext) {
      if (scriptContext.type == scriptContext.UserEventType.CREATE) {
          var recNew = scriptContext.newRecord;
  
          var idCustomer = recNew.getValue('entity');
          var idUser = runtime.getCurrentUser().id;
          var idForm = recNew.getValue('customform');     
  
          // Set form from user department
          var idNewForm = defaulting.determineSOForm(idUser, null, idCustomer);
  
          if (idForm != idNewForm) {
              recNew.setValue({
                  fieldId : 'customform',
                  value : idNewForm
              });
  
              idForm = idNewForm;
          }
      }
  }
  </code></pre>
  
  <p>Using the Script Debugger I can step through this and it all works fine, but the customform is not set at all. I have read that the customform field cannot be set in the beforeLoad event of a UserEvent Script but now I am lost on how to accomplish this.</p>