how to access a custom sublist on a suitescript
# ask-stanley-ai
i
how to access a custom sublist on a suitescript
c
AI generated answer (using internal Slack threads):
To access a custom sublist on a SuiteScript, you can use the
currentRecord
module to get the current record and then use the
selectLine
,
setCurrentSublistValue
, and
commitLine
methods to manipulate the sublist. Here is an example:
Copy code
javascript
//ClientScript

function calledViaSublistButtonClick() { 

var myRecord = currentRecord.get();

            myRecord.selectLine({
              sublistId: 'sublist_2',
              line: 0
            });

            myRecord.setCurrentSublistValue({
              sublistId: 'sublist_2',
              fieldId: 'fee_item',
              value: 100,
              ignoreFieldChange: true
            });

            myRecord.commitLine({
              sublistId: 'sublist_2'
            });
}
In this example,
sublist_2
is the ID of the sublist,
fee_item
is the ID of the field in the sublist, and
100
is the value you want to set for the field. Please note that the sublist ID and field ID should be correct. If the sublist is a static list type sublist, it doesn't have SuiteScript support. If you want a scriptable custom sublist, you might want to create a custom child record sublist. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.850488722
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.847259045
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.841562331
Please provide your feedback on this answer.