javanetsuitesuitetalk

NetSuite SuiteTalk SOAP Api: Update Certain Fields ONLY on a Record


We are hitting a problem with updating a NetSuite Sales Order (specifically we're updating a custom field) but are bouncing off some Read-only fields that we don't even explicitly write to in our code.

We retrieve the order, update the custom field and then call WriteResponse rc = this.nsPort.update(order); where order is an instance of SalesOrder pulled by internalID and nsPort is an instance of NetSuitePortType. The call to update() fails with an exception:

java.lang.Exception: You do not have permissions to set a value for element subtotal
due to one of the following reasons: 1) The field is read-only; 2) An associated feature
is disabled; 3) The field is available either when a record is created or updated, but 
not in both cases.

Which field is read-only is immaterial here, it just matters that we're (unintentionally) sending an update back that involves read-only fields.

It strikes me that we'd ideally only send an update that writes to just the custom field we're interested in.

Is there any way to pull an a record from NetSuite and then update just certain fields? Or is there a way to inform SuiteTalk to just update certain fields when we call update()?


Solution

  • If you just want to update certain fields, only send those fields that you want updated along with the internalId. For example, to update just the memo, and a custom field on a sales order use (in python):

    sales_order = soap.sales.SalesOrder(
        internalId=12,
        memo='I updated the memo, but I did not shoot the deputy',
        customFieldList=soap.core.CustomFieldList(customField=[
            soap.core.CustomString(scriptId='custbody_memo', value='I also did not shoot the deputy'),
        ])
    )
    soap.update(sales_order)
    

    This will generate an xml that includes only the internalId, the memo, the custom body memo field. Netsuite will only update those fields included in the soap message.