ShippingGuy
ShippingGuy

Reputation: 21

Update Custom Address Field in Netsuite using SuiteScript 2.0

I created a new custom field in the 'US' address form called 'email', so I can have an email address associated with both the bill to and ship to on a sales order in Netsuite. I am trying to update this field using Suitescript 2.0, but cannot seem to save the changes. Can anyone give any insight?

var salesorder = record.load({
    type: record.Type.SALES_ORDER, 
    isDynamic: true,
    id: 6835
});

var shippingAddressSubrecord = salesorder.getSubrecord({fieldId : 'shippingaddress'});
var email = shippingAddressSubrecord.getValue({fieldId : 'custrecord_email_address' }); //returns correctly
shippingAddressSubrecord.setValue({fieldId : 'custrecord_email_address', value: '[email protected]', ignoreFieldChange: true });

var salesorderid = salesorder.save({enableSourcing: true, ignoreMandatoryFields: true});

This gives the error: "type":"error.SuiteScriptError","name":"OPERATION_IS_NOT_ALLOWED","message":"The subrecord line has already been committed or cancelled. The previous subrecord reference is no longer valid. You must get another reference to the subrecord in order to perform this operation.",

Upvotes: 0

Views: 2261

Answers (1)

felipechang
felipechang

Reputation: 924

Depends, which script type is this? User Even scripts for example, loading/saving the record would result in an error.

Upvotes: -1

Related Questions