RE: How to update a record using external id through NetSuite Restlet?
Hi,
I have a record and I have set a value in external id at the time of record creation. Now want to update that record using that external id. How can I do this in restlet?
Regards
Titu Singh
To update a record in NetSuite using an external ID through a Restlet, you can follow these steps:
- In your Restlet code, create a new instance of the appropriate NetSuite record type you wish to update. For example, if you want to update a customer record, you would create a new instance of the
N/recordmodule’scustomerobject. - Use the
N/recordmodule’sloadmethod to load the record with the external ID. Theloadmethod takes two parameters: the record type and the external ID. For example:var customerRecord = record.load({
type: record.Type.CUSTOMER,
id: externalId
});
- Once you have loaded the record, you can update its fields as necessary. For example, to update the customer’s phone number:
customerRecord.setValue({
fieldId: 'phone',
value: '123-456-7890'
});
- Finally, use the
N/recordmodule’ssubmitFieldsmethod to save the changes to the record:record.submitFields({
type: record.Type.CUSTOMER,
id: externalId,
values: {
phone: '123-456-7890'
}
});
Note that you can also use the
N/recordmodule’ssubmitFieldsmethod to update the record without first loading it usingload.In both cases, the
idparameter should be set to the external ID of the record you want to update.