title: NetSuite API: Update Custom Object Field
body: <p>I am trying to update a field in a custom object, but when I do I get an error <code>java.lang.NullPointerException</code>.</p>
  
  <p>There is also this in the Code object of the exception: <code>http://schemas.xmlsoap.org/soap/envelope/:Server.userException</code>. <a href="https://stackoverflow.com/questions/3833369/axisfault-what-does-server-userexception-mean">This S/O thread</a> indicates it may be something wrong with the request I sent that caused the server to throw the exception. But what?  There are no details in the exception.</p>
  
  <p>As far as I can see I'm following the update example in "SuiteTalk (Web Services) Platform Guide" with the exception that this is a "CustomRecord" an not a "Customer", so I had to make some changes.</p>
  
  <p>This is the method I have to help updating CustomRecords.  The error happens in the final line where I actually make the request:</p>
  
  <pre><code>private static void UpdateCustomRecordValue(CustomRecord customRecord, string fieldName, string newValue, NetSuiteService netsuiteService)
  {
      var field = customRecord.customFieldList.Where(custField =&gt; custField.scriptId == fieldName).FirstOrDefault();
  
      if (field == null) return;
  
      var updateRecord = new CustomRecord();
      updateRecord.scriptId = customRecord.scriptId;
  
      CustomFieldRef[] custFieldList = new CustomFieldRef[] {
          new StringCustomFieldRef
          {
              value = newValue, 
              scriptId = field.scriptId
          }
      };
  
      updateRecord.customFieldList = custFieldList;
      var updateResponse = netsuiteService.update(updateRecord);
  
  }
  </code></pre>