Creating Search Columns in SuiteScript for NetSuite

Master search column creation in SuiteScript to enhance search results with specific fields and their properties.

·3 min read·View Oracle Docs

Creating new search columns in SuiteScript allows developers to specify fields that should be represented in the search results. A search column is an object that corresponds to a specific field in a record and is instrumental in customizing search output to business needs.

What is a Search Column?

A search column represents a specific field on a record that you want to include in the returned search results. For instance, if you want to display the Sales Rep field from a customer record in your search results, you would create a column for that field when defining your search criteria.

Important Considerations

When creating search columns, you should be aware of the following:

  • Field Internal IDs: Directly referencing the text value of a list/record type field is prohibited. Instead, use the internal ID of the field. If you need to use the text value, you can implement a formula with name: 'formulatext'.
  • Sorting Limitations: After a search column has been created, its sort order cannot be changed. If you use the same column in multiple searches, the original sort order specified with options.sort will be retained.

How to Create a Search Column

To create a search column in SuiteScript, you'll use the search.createColumn(options) method. The options object allows you to define various parameters for your search column.

Parameters

ParameterTypeRequired / OptionalDescription
options.namestringrequiredName of the search column, linked to the field.
options.joinstringoptionalJoin ID for the search column.
options.summarystringoptionalSummary type for the column.
options.formulastringoptionalFormula for derived column values.
options.functionstringoptionalSpecial function applied to the column.
options.labelstringoptionalLabel for the search column.
options.sortstringoptionalSpecifies the sorting order of the column.

Example Code

Here’s a basic example of creating a search column using SuiteScript:

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

This snippet creates a column for the currency field and sets it to sort in ascending order.

Error Handling

While crafting your search column, you might encounter several errors:

  • SSS_INVALID_SRCH_COLUMN_SUM: Thrown when an invalid column summary type is used in the options.summary parameter.
  • INVALID_SRCH_FUNCTN: Returned if an unrecognized function is provided for the search column.
  • SSS_MISSING_REQD_ARGUMENT: Occurs when a required parameter is missing during column creation.

Conclusion

By effectively utilizing the search.createColumn method, developers can tailor their SuiteScript searches to meet specific business requirements, improving the clarity and relevance of search outputs.

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

Frequently Asked Questions (4)

Do search columns in SuiteScript retain their sort order if used in multiple searches?
Yes, once a sort order for a search column is specified with `options.sort`, it cannot be changed, and this order will be retained across multiple searches.
What error might occur if I use an invalid summary type for a search column?
You might encounter the `SSS_INVALID_SRCH_COLUMN_SUM` error if an invalid column summary type is specified in the `options.summary` parameter.
Can I use the text value of a list/record type field directly when creating a search column?
No, you should use the field's internal ID instead. If you need the text value, you can implement a formula with `name: 'formulatext'`.
What happens if a required parameter is missing when creating a search column in SuiteScript?
If a required parameter is missing, you will encounter the `SSS_MISSING_REQD_ARGUMENT` error during the creation of the search column.
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 Searches

View all Searches articles →