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
You’ll need to search for the record using the external ID field. That will provide you with the internal ID which you can then use to load the record.
I am doing the same but did not get success.
function getRecordId(datain) {
var a_filter = [];
var a_column = [];
a_filter.push(new nlobjSearchFilter(‘externalid’, null, ‘is’, datain.loanid));
a_column.push(new nlobjSearchColumn(‘internalid’));
var o_record_search = nlapiSearchRecord(‘customrecord_aggregator_sale’, null, a_filter, a_column);
if (o_record_search) {
i_record_id = o_record_search[0].getId();
nlapiLogExecution(‘DEBUG’, recordid + ‘ >>>’, i_record_id);
}
return i_record_id;
}
function update_sale(datain, i_record_id) {
var rec = nlapiLoadRecord(‘customrecord_aggregator_sale’, i_record_id);
rec.setFieldValue(‘custrecord_as_state’, datain.state);
It looks like your saved search isn’t returning the result then.
I’d suggest that you get the saved search working in NetSuite and then use a tool like this to get the saved search code:
https://chrome.google.com/webstore/detail/netsuite-search-export/gglbgdfbkaelbjpjkiepdmfaihdokglp
At first sight, you might need ‘anyof’ instead of ‘is’.
Thanks,
Chris
The tool is asking for Record Type Script ID. What should I mention in this?
With this tool, you create your saved search, save it, then edit.
When you edit, you will see a link at the top right to get the code for the search.
Yes, I got below and after implementing the same did not get any resolution.
var customrecord_aggregator_saleSearch = nlapiSearchRecord(“customrecord_aggregator_sale”,null,
[
[“externalid”,”anyof”,”5114509000011053″]
],
[
new nlobjSearchColumn(“internalid”)
]
);
Did the search return a result in NetSuite?
Yes, If you want then I can share my complete code with you?
And what are you seeing? No results returned?