Tip 36: Get any list id to use it as List/Record source type in select field of NetSuite SuiteLet script

While working on a SuiteLet form, have you ever faced problem on setting the exact source ID of a List/Record field. If so, you are not alone. Most of us might have faced such situation. I personally have faced this several times.

Here is a small tip for you, so next time you won’t have to spend much time on retrieving source ID.

Here is the scenario.

Requirement: Create a SuiteLet Form which will include State, Country, Class and some other List/Record fields.

Code Sample to add fields to form:

var fldClass = form.addField({
id : ‘custpage_class’,
type : serverWidget.FieldType.SELECT,
label : ‘Class’,

source: <CLASS SOURCE ID>
});

var fldState = form.addField({
id : ‘custpage_state’,
type : serverWidget.FieldType.SELECT,
label : ‘State’,
source: <STATE SOURCE ID>
});
var fldState = form.addField({
id : ‘custpage_country’,
type : serverWidget.FieldType.SELECT,
label : ‘Country’,
source: <COUNTRY SOURCE ID>
});

Now here, what if we don’t know what’s the source ID. There is an easy way to get any of the List/Record source ID.

Step 1:

Go To Customization>List, Records & Fields > Transaction Body Field > New

On the New field record, select Type of the field as “List/Record”, and on List Record dropdown, select the desired List or record. Like here in this case, I will choose Class under List/Record dropdown as below:

Step 2: Now Open Inspect Element on the browser on this page and on Console, type below code:

nlapiGetFieldValue(“selectrecordtype”);

Once you click enter, it will return that source ID as below:

Here you can see the source ID of “Class” is “-101”.

Hope this small tip will help you.

Happy Coding 🙂

Thank You

Ashabari Jena