search.lookupFields Method for SuiteScript in NetSuite
The search.lookupFields method in SuiteScript retrieves body fields from NetSuite records, offering single and multi-select field handling.
The search.lookupFields method in SuiteScript facilitates the retrieval of body fields from a NetSuite record efficiently. This method supports both synchronous and promise-based approaches, making it versatile for developers.
Method Description
The search.lookupFields(options) method enables the search for one or more fields on a specified record. It utilizes the following syntax for joined-field lookups:
join_id.field_nameReturns
- Object | Object[]
- A single select field returns an object with
valueandtextproperties. - A multi-select field returns an array of objects comprising
valueandtextpairs.
- A single select field returns an object with
Supported Script Types
This functionality is applicable for both client and server scripts in SuiteScript.
Governance
The method operates with a governance unit cost of 1.
Parameters
The options parameter is a necessary JavaScript object containing:
| Parameter | Type | Required/Optional | Description |
|---|---|---|---|
options.type | enum | Required | Specifies the type of search for the fields. |
options.id | string | Required | The internal ID for the record, such as 777 or 87. |
options.columns | `string | string[]` | Required |
Error Handling
SSS_INVALID_SRCH_COL: This error occurs if an invalid column is referenced in theoptions.columnsparameter.SSS_MISSING_REQD_ARGUMENT: Triggered when a required argument is missing in the request.
Code Example
Here’s a simple usage example of the search.lookupFields method:
1// Add additional code2...3var fieldLookUp = search.lookupFields({4 type: search.Type.SALES_ORDER,5 id: '87',6 columns: ['entity', 'subsidiary', 'name', 'currency']7});8...9// Add additional codeImportant Notes
In the context of search and lookup operations, be aware that custom multiselect fields of type ‘long text’ are truncated based on the account language settings. In standard single-language accounts, truncation occurs at 3,900 characters, while accounts with multiple languages truncate values at 1,300 characters.
Related Topics
For further reading on related functionalities, consider checking the N/search Module and examining SuiteScript 2.x Modules for a comprehensive understanding of the SuiteScript framework.
Key Takeaways
- The
search.lookupFieldsmethod retrieves body fields asynchronously or synchronously. - It returns distinct structures for single and multi-select fields.
- Error handling is essential for correct implementation, especially concerning missing or invalid arguments.
- Governance limits are applied per execution of the method.
- Truncation limits based on account capabilities can affect the retrieval of long text fields.
Frequently Asked Questions (4)
In which script types can the search.lookupFields method be used?
What happens if I reference an invalid column in the options.columns parameter?
How are the results structured when using search.lookupFields with single and multi-select fields?
Are there any character limitations for custom multiselect fields when using search.lookupFields?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- Binary File Support in N/https Module for SuiteScript
SuiteScript enhances capabilities with binary file support in the N/https module, allowing improved data handling in external communications.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
