Creating Search Columns in SuiteScript for NetSuite

Creating search columns in SuiteScript allows precise retrieval of fields in search results, enhancing data analysis and reporting.

·3 min read·View Oracle Docs

Creating search columns is fundamental in SuiteScript, allowing developers to fetch specific field values when executing searches against records. This article provides an overview of how to create search columns, discusses important considerations, returns data, and outlines potential errors you might encounter during the process.

What is a Search Column?

A search column in SuiteScript represents a field on a record. When you create a column for a specific field—for example, the Sales Rep field on a customer record—and include it in your search criteria, this field's value will appear in the search results subsequently.

Important Considerations

As you create search columns, there are some critical points to keep in mind:

  • Internal IDs: When dealing with a list or record type field, use the field's internal ID instead of its text value. If you need to use the text value, create a filter or column that utilizes a formula via name: 'formulatext'.
  • Sort Order: Once a column is created, its sort order cannot be changed on the fly. If used in multiple searches, the initial sort order specified via the options.sort parameter remains fixed.

Method Syntax

To create a new search column, you'll use the search.createColumn(options) method. The following parameters can be included:

ParameterTypeRequired/OptionalDescription
options.namestringrequiredName of the search column.
options.joinstringoptionalJoin ID for the search column.
options.summarystringoptionalSummary type for the column.
options.formulastringoptionalFormula for the search column.
options.functionstringoptionalSpecial function for the search column.
options.labelstringoptionalLabel for the search column.
options.sortstringoptionalSort order of the column.

Example Code

Here’s a basic example of how to create a search column in SuiteScript:

suitescript
var currencyColumn = search.createColumn({
name: 'currency',
sort: search.Sort.ASC
});

This creates a column for the currency field and specifies that the results should be sorted in ascending order by this column.

Error Handling

When creating search columns, you may encounter the following errors:

Error CodeMessageThrown If
SSS_INVALID_SRCH_COLUMN_SUMInvalid summary type or incorrect syntax.The options.summary is not valid.
INVALID_SRCH_FUNCTNAn unknown function was provided.The function does not match expected formats.
SSS_MISSING_REQD_ARGUMENTMissing required argument specified.One or more required parameters are missing.

Conclusion

Understanding how to create search columns effectively can greatly enhance data retrieval capabilities within SuiteScript. By carefully managing parameters and error handling, developers can ensure efficient and accurate queries in their NetSuite applications.

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

Key Takeaways

  • Search columns represent fields on records for customized search results.
  • Use internal IDs for list/record type fields when defining columns.
  • Sort orders are fixed after column creation and cannot be overridden in subsequent searches.
  • Familiarize yourself with common errors in creation to streamline debugging and development processes.

Frequently Asked Questions (4)

Do I need to use internal IDs for list or record type fields when creating search columns in SuiteScript?
Yes, when dealing with a list or record type field, you should use the field's internal ID instead of its text value. If the text value is necessary, a formula utilizing 'formulatext' can be used.
Can I change the sort order of a search column after it is created in SuiteScript?
No, the sort order of a search column cannot be changed after it is created. The initial sort specified via the 'options.sort' parameter will remain fixed for multiple searches.
What are the required parameters for creating a search column using 'search.createColumn' in SuiteScript?
The only required parameter for creating a search column using 'search.createColumn' is 'options.name', which specifies the name of the search column.
What error might occur if an invalid summary type is used when creating a search column?
If an invalid summary type or incorrect syntax is used when creating a search column, you would encounter the 'SSS_INVALID_SRCH_COLUMN_SUM' error.
Source: Errors 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 →