Creating Search Columns with SuiteScript in NetSuite

Create and manage search columns in SuiteScript to customize search results effectively and efficiently in NetSuite.

·3 min read·View Oracle Docs

What Are Search Columns in SuiteScript?

Search columns in SuiteScript are used to define and include specific fields from various records in your search results. By using the search.createColumn method, developers can effectively manage what appears in the output of a search.

Creating a search column is crucial for obtaining tailored results based on specific fields of interest. For instance, adding a column for the "Sales Rep" field will ensure that this information is part of the search output, making data analysis easier and more relevant to business needs.

Important Considerations for Creating Search Columns

When defining search columns, keep the following points in mind:

  • Field ID Usage: Always use the internal ID of a field for records or lists. If you need to utilize a text value, you can do so via a formula, specifically using name: 'formulatext'.
  • Sort Order Entrapment: Once a column is created and a sort order is applied, it cannot be changed in subsequent searches. Hence, care should be taken while deciding the sort order using the options.sort parameter.

How to Create a Search Column

The following outlines the methodology for creating a search column using SuiteScript:

suitescript
// Sample code to create a currency column in SuiteScript
var currencyColumn = search.createColumn({
name: 'currency',
sort: search.Sort.ASC
});

This code snippet illustrates the basic syntax necessary to create a column object that specifies which field to include in your search results.

Parameters for Creating Search Columns

Several parameters can be provided while creating a search column:

ParameterTypeRequired/OptionalDescription
options.namestringRequiredThe name of the search column, typically an internal field ID.
options.joinstringOptionalIdentifier for joining datasets.
options.summarystringOptionalType of summary for the column.
options.formulastringOptionalFormula applied to the column.
options.functionstringOptionalAny special functions associated with the column.
options.labelstringOptionalCustom label for the search column.
options.sortstringOptionalDefines the sorting approach for the column output.

Error Codes

While creating search columns, you might encounter errors. Here are some notable codes:

  • SSS_INVALID_SRCH_COLUMN_SUM: An invalid summary type or syntax error occurred in the search column.
  • INVALID_SRCH_FUNCTN: This indicates an unrecognized function was used.
  • SSS_MISSING_REQD_ARGUMENT: Retorted when a mandatory parameter is absent.

Conclusion

Utilizing search columns within SuiteScript allows developers to create precise and functional searches tailored to the specific requirements of their business processes.

Who This Affects

  • Developers: Responsible for writing and maintaining SuiteScript.
  • Administrators: Who define how data is retrieved via search functions.

Key Takeaways

  • Search columns specify fields to include in search results.
  • Always utilize internal IDs for field representation.
  • Once a column's sort order is set, it cannot be changed for future uses.
  • Proper error handling during column creation is crucial for smooth execution.

Frequently Asked Questions (4)

What parameters are required when creating a search column in SuiteScript?
The only required parameter when creating a search column in SuiteScript is `options.name`, which represents the internal field ID.
Can I change the sort order of a search column after it is created?
No, once a column is created and a sort order is applied using the `options.sort` parameter, it cannot be changed in subsequent searches.
What should I do if I encounter an SSS_INVALID_SRCH_COLUMN_SUM error?
The SSS_INVALID_SRCH_COLUMN_SUM error indicates an invalid summary type or a syntax error in the search column. Review your usage of summary types and correct any syntax issues.
How do I include a text value in a search column if only internal IDs are allowed?
You can include a text value by using a formula with `name: 'formulatext'`, which allows you to manipulate text values within a search column.
Source: Parameters 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 →