Get Current Record ID in the Client Script

Hello, I have a button created with the client script on a inventory item record. On clicking the button, it opens up a suitelet in new window. I want to store the inventory item record internal id and then pass it to the suitelet to save it in a field. I tried using context for getting currentRecordId, but am unsuccessful. Please help me in solving this.


Rookie Asked on September 12, 2019 in SuiteScript.

If you are using suitescript 1 you can use

var internalId = nlapiGetRecordId();

if you are using suitescript use n/record or n/currentRecord 2

on July 6, 2020.
Add Comment
3 Answer(s)

Try currentRecord.get().id, that should contain the id of the record.  context.currentRecord would not have the id since the context of the record would not be passed to the client since its just being called by a button.

Intermediate Answered on September 12, 2019.
Add Comment

By the way, if you are using SS 1.0, it is

var current_record_id = nlapiGetRecordId()
.  It works whether the record is in read or edit mode equally.

Rookie Answered on September 12, 2019.
Add Comment

Using the N/currentRecord module in your client script:

function printLabel(){
var currRec = cr.get();
var url = currRec.getValue({
fieldId : ‘custpage_url_text’
});’&items=[“inventoryitem:’ + +'”]’);

Embed your Suitelet URL in a hidden field on the item record, then you can pass the ID in a URL parameter to the Suitelet

Beginner Answered on September 12, 2019.

so that printLabel is a custom function on your client script, load that into your User Event Script, beforeLoad.

Reference the printLabel function or whatever you want to call it in the beforeLoad code, form.addButton.

on September 12, 2019.
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   Become a Sponsor   Become a Sponsor