How to Load in Custom Scripts in a SuiteScript by the List ID   

in September 28th, 2024

Using custom lists in SuiteScripts is an important skill, and knowing how to load them can be tricky. This difficulty has less to do with the complexity of the task itself and is much more attributable to a lack of documentation in the NetSuite ecosystem about how to accomplish this.

Loading a Custom List: SuiteScript Code Sample

The code snippet below explains how to load and use a custom list in SuiteScript. Be sure to edit this code example to meet the needs of your particular use case.

//Use the record module to load in the script. 
//The record "type" must be "customlist".
var customList = record.load({ type: "customlist", id: listId });
//Loop over the list options as follows
var numLines = customList.getLineCount({ sublistId: "customvalue" });
for (var i = 0; i < numLines; i++) {
    //Grab the necessary option values. A few example are shown here. 
    var optionId = customList.getSublistValue({
        sublistId: "customvalue",
        fieldId: "valueid",
        line: i,
    });
    var optionLabel = customList.getSublistValue({
        sublistId: "customvalue",
        fieldId: "value",
        line: i,
    });
}

That's it! Hopefully, this article gave you a helpful start as you work to load custom lists in SuiteScript! If you have any questions about this process or need assistance with your code customization, contact our team for assistance with your project!

Author: Sam Gagliardi


Got stuck on a step in this article?

We like to update our blogs and articles to make sure they help resolve any troubleshooting difficulties you are having. Sometimes, there is a related feature to enable or a field to fill out that we miss during the instructions. If this article didn't resolve the issue, please use the chat and let us know so that we can update this article!


Oracle NetSuite Alliance Partner & Commerce Partner

If you have general questions about SuiteCommerce or more specific questions about how our team can support your business as you implement NetSuite or SuiteCommerce, feel free to contact us anytime. Anchor Group is a certified Oracle NetSuite Alliance Partner and Commerce Partner equipped to handle all kinds of NetSuite and SuiteCommerce projects, large or small!

 
 

Want to keep learning?

Our team of NetSuite professionals has written articles on a wide variety of NetSuite topics, from SuiteCommerce tips, to recommended NetSuite solutions, to available support services, and more! 

Your cart