update

The update operation is used to update an instance of a record in NetSuite. It is similar to the updateList operation, which allows users to update more than one record at a time.

Only the fields that have been populated in each submitted record are updated in the system. If a field has NOT been populated, it is not updated in the system and it retains its previous value. If a field is set to an empty string, the previous value of the field is replaced with an empty string. Therefore, when updating records, you should get the desired record, instantiate a new record of the same type, populate only the fields that require an update and then submit the updated record. This ensures that only the fields requiring an update are written on submission.

Important:

Calculated and hidden fields in records are always updated by the system unless your service explicitly overrides the system values. For more information, see Hidden Fields. Also, custom fields can only be set to NULL by submitting the field in nullFieldList. For more information, see CustomFieldList.

To ensure that the most recent data for a specific record is being modified, when a Web service request is received, the values for that record are retrieved at the time of the Update request rather than with the initial Get of the associated record. The record is then updated by the values submitted in the request. It is possible that between the time of the retrieval of the record field values and the submission of the updated fields that the record is altered from another source (for example from a UI submission). In this case an error message is returned to indicate that the fields have been modified since your service retrieved the record.

Although records of a particular type may be used in multiple integration scenarios, each record instance can only have a single external ID value. To maintain data integrity, only a single integrated application can set and update external ID values for each record type. External ID values for all records of a particular type must all come from the same external application.

Note:

As of the 2011.2 endpoint, when a record is updated and the values that are sent are exactly the same as the existing record values, the record is not reset (nothing happens). In previous endpoints, sometimes records were reset in these cases.

Request

The UpdateRequest type is used for the request. It contains the following fields.

Element Name

XSD Type

Notes

record

Record

Contains an array of record objects. The record type is an abstract type so an instance of a type that extends record must be used—such as Customer or Event.

Response

The UpdateResponse type is used for the response. It contains the following fields.

Element Name

XSD Type

Notes

response

WriteResponse

Contains details on the status of the operation and a reference to the updated record.

Faults

This operation can throw one of the following faults. See SOAP Fault Status Codes for more information on faults.

Sample Code

SOAP Request

In the following example, a customer's companyName is updated. The internal ID for the customer must be provided in the request.

          <soap:Body>
<platformMsgs:update>
   <platformMsgs:record internalId="980" xsi:type="listRel:Customer">
      <listRel:companyName>Shutter Fly Corporation</listRel:companyName>
   </platformMsgs:record>
</platformMsgs:update>
</soap:Body> 

        

SOAP Response

          <soapenv:Body>
<updateResponse xmlns="urn:messages_2017_1.platform.webservices.netsuite.com">
<writeResponse xmlns="urn:messages_2017_1.platform.webservices.netsuite.com">
   <ns1:status isSuccess="true" xmlns:ns1="urn:core_2017_1.platform.webservices.netsuite.com"/>
      <baseRef internalId="980" type="customer" xsi:type="ns2:RecordRef"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns:ns2="urn:core_2017_1.platform.webservices.netsuite.com"/>
</writeResponse>
</updateResponse>
</soapenv:Body> 

        

C#

           private void updateCustomer()
{
   // This operation requires a valid session
   this.login( true );
   
   Customer customer = new Customer();
   
   // Get nsKey for update
   _out.write( "\nEnter nsKey for customer record to be updated : " );
   customer.internalId = _out.readLn().ToUpper();
   
   // Set name and email
   customer.entityId = "XYZ 2 Inc";
   customer.companyName = "XYZ 2, Inc.";
   customer.email = "bsanders@xyz.com";
   
   // Populate the address. Updating a list through WS results in the
   // entire contents of the previous list being replaced by the new
   // list.
   CustomerAddressbook address = new CustomerAddressbook();
   address.defaultBilling = true;
   address.defaultBillingSpecified = true;
   address.defaultBilling = false;
   address.defaultBillingSpecified = true;
   address.label = "Billing Address";
   address.addr1 = "4765 Sunset Blvd";
   address.city = "San Mateo";
   address.state = "CA";
   address.country = Country._unitedStates;
   
   // Attach the address to the customer
   CustomerAddressbookList addressList = new CustomerAddressbookList();
   CustomerAddressbook[] addresses = new CustomerAddressbook[1];
   addresses[0] = address;
   addressList.addressbook = addresses;
   customer.addressbookList = addressList;
   
   // Invoke add() operation
   WriteResponse response = _service.update( customer );
   
   // Process the response
   if ( response.status.isSuccess )
   {
      _out.info(
      "\nThe following customer was updated successfully:" +
      "\nkey=" + ((RecordRef) response.baseRef).internalId +
      "\nentityId=" + customer.entityId +
      "\ncompanyName=" + customer.companyName +
      "\nemail=" + customer.email +
      "\naddressbookList[0].label=" + customer.addressbookList.addressbook[0].label );
   }
   else
   {
      _out.error( getStatusDetails( response.status ) );
   }
} 

        

Java

          public void updateCustomer() throws RemoteException,
ExceededUsageLimitFault, UnexpectedErrorFault, InvalidSessionFault,
ExceededRecordCountFault {
   // This operation requires a valid session
   this.login(true);
   
   Customer customer = new Customer();
   
   // Get nsKey for update
   _console.write("\nEnter nsKey for customer record to be updated : ");
   customer.setInternalId(_console.readLn().toUpperCase());
   
   // Set name and email
   customer.setEntityId("XYZ 2 Inc");
   customer.setCompanyName("XYZ 2, Inc.");
   customer.setEmail("bsanders@xyz.com");
   
   // Populate the address. Updating a list through WS results in the
   // entire contents of the previous list being replaced by the new
   // list.
   CustomerAddressbook address = new CustomerAddressbook();
   address.setDefaultBilling(Boolean.TRUE);
   address.setDefaultShipping(Boolean.FALSE);
   address.setLabel("Billing Address");
   address.setAddr1("4765 Sunset Blvd");
   address.setCity("San Mateo");
   address.setState("CA");
   address.setCountry(Country._unitedStates);
   
   // Attach the address to the customer
   CustomerAddressbookList addressList = new CustomerAddressbookList();
   CustomerAddressbook[] addresses = new CustomerAddressbook[1];
   addresses[0] = address;
   addressList.setAddressbook(addresses);
   customer.setAddressbookList(addressList);
   
   // Invoke add() operation
   WriteResponse response = _port.update(customer);
   
   // Process the response
   if (response.getStatus().isIsSuccess()) {
      _console.info("\nThe following customer was updated successfully:"
      + "\nkey="
      + ((RecordRef) response.getBaseRef()).getInternalId()
      + "\nentityId="
      + customer.getEntityId()
      + "\ncompanyName="
      + customer.getCompanyName()
      + "\nemail="
      + customer.getEmail()
      + "\naddressbookList[0].label="
      + customer.getAddressbookList().getAddressbook(0)
      .getLabel());
   } else {
      _console.error(getStatusDetails(response.getStatus()));
   }
} 

        

Updating Record Lists

When updating a list of records (a sublist) within a business record you CANNOT update a specific item in the list. Instead you must interact with the sublist as a whole. For details, see Sublists in SOAP Web Services.

Related Topics

SuiteTalk SOAP Web Services Platform Overview
SOAP Web Services Development Considerations
SOAP Web Services Processing
SOAP Web Services Operations
SOAP Web Services Standard Operations
SOAP Web Services List Operations
SOAP Web Services Asynchronous Operations

General Notices