Records
SuiteScript Sublists
Working with Sublists
SuiteScript sublists manage line items on records like sales orders.
Understanding SuiteScript Sublists
In SuiteScript, sublists are an essential part of handling line items within records such as sales orders, invoices, and purchase orders. They allow you to interact with multiple line items as part of a single record.
Sublists are used to represent tabular data, where each row is an individual line item and each column represents a field related to the line item, such as quantity, price, or description.
Accessing Sublists in SuiteScript
To work with sublists in SuiteScript, you must first load or create a record. Once you have the record, you can use the getSublist
function to access a specific sublist by its ID. Common sublist IDs include 'item' for transaction line items and 'expense' for expense reports.
Modifying Sublist Data
Modifying sublist data involves updating line items or adding new ones. To update a line item, use the setLineItemValue
function to specify the sublist ID, field ID, line number, and new value.
Adding and Removing Lines
Adding a new line involves inserting a row into the sublist using the insertLineItem
function. To remove a line, use the removeLineItem
function, specifying the sublist ID and line number.
Saving Changes to the Record
After making changes to a sublist, you must save the record to ensure all updates are persisted. Use the submitRecord
function to save the record.
Best Practices for Managing Sublists
- Always validate data before setting it on a sublist to avoid errors.
- Use loops effectively to iterate over sublist items when performing batch operations.
- Ensure that you handle exceptions and errors gracefully to prevent data corruption.
- Previous
- Fields
- Next
- Transactions