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

Rookie Asked on September 2, 2021 in SuiteScript.
Add Comment
13 Answer(s)

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.

Intermediate Answered on September 7, 2021.
Add Comment

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);

Rookie Answered on September 7, 2021.
Add Comment

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

 

Intermediate Answered on September 7, 2021.
Add Comment

The tool is asking for Record Type Script ID. What should  I mention in this?

Rookie Answered on September 7, 2021.
Add Comment

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.

Intermediate Answered on September 7, 2021.
Add Comment

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”)
]
);

 

Rookie Answered on September 7, 2021.
Add Comment

Did the search return a result in NetSuite?

Intermediate Answered on September 7, 2021.
Add Comment

Yes, If you want then I can share my complete code with you?

Rookie Answered on September 7, 2021.
Add Comment

Yes please.

Intermediate Answered on September 7, 2021.
Add Comment

And what are you seeing? No results returned?

Intermediate Answered on September 7, 2021.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor