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.

·2 min read·View Oracle Docs

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:

javascript
join_id.field_name

Returns

  • Object | Object[]
    • A single select field returns an object with value and text properties.
    • A multi-select field returns an array of objects comprising value and text pairs.

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:

ParameterTypeRequired/OptionalDescription
options.typeenumRequiredSpecifies the type of search for the fields.
options.idstringRequiredThe internal ID for the record, such as 777 or 87.
options.columns`stringstring[]`Required

Error Handling

  • SSS_INVALID_SRCH_COL: This error occurs if an invalid column is referenced in the options.columns parameter.
  • 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:

javascript
1// Add additional code
2...
3var fieldLookUp = search.lookupFields({
4 type: search.Type.SALES_ORDER,
5 id: '87',
6 columns: ['entity', 'subsidiary', 'name', 'currency']
7});
8...
9// Add additional code

Important 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.lookupFields method 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.

Source: This article is based on Oracle's official NetSuite documentation.

Frequently Asked Questions (4)

In which script types can the search.lookupFields method be used?
The search.lookupFields method is applicable for both client and server scripts in SuiteScript.
What happens if I reference an invalid column in the options.columns parameter?
If an invalid column is referenced in the options.columns parameter, it will trigger an 'SSS_INVALID_SRCH_COL' error.
How are the results structured when using search.lookupFields with single and multi-select fields?
For single select fields, the method returns an object with 'value' and 'text' properties. For multi-select fields, it returns an array of objects, each containing 'value' and 'text' pairs.
Are there any character limitations for custom multiselect fields when using search.lookupFields?
Yes, custom multiselect fields of type ‘long text’ are truncated based on account language settings. In single-language accounts, truncation occurs at 3,900 characters, whereas in multi-language accounts, it truncates values at 1,300 characters.
Source: Syntax Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in Integration

View all Integration articles →