Creating Search Columns with SuiteScript in NetSuite
Learn to create and manage search columns in SuiteScript for tailored search results in NetSuite. What Are Search Columns in SuiteScript?
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.sortparameter.
How to Create a Search Column
The following outlines the methodology for creating a search column using SuiteScript:
// Sample code to create a currency column in SuiteScriptvar 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:
| Parameter | Type | Required/Optional | Description |
|---|---|---|---|
options.name | string | Required | The name of the search column, typically an internal field ID. |
options.join | string | Optional | Identifier for joining datasets. |
options.summary | string | Optional | Type of summary for the column. |
options.formula | string | Optional | Formula applied to the column. |
options.function | string | Optional | Any special functions associated with the column. |
options.label | string | Optional | Custom label for the search column. |
options.sort | string | Optional | Defines 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?
Can I change the sort order of a search column after it is created?
What should I do if I encounter an SSS_INVALID_SRCH_COLUMN_SUM error?
How do I include a text value in a search column if only internal IDs are allowed?
Was this article helpful?
More in Searches
- Creating Searches with SuiteScript in NetSuite
Create and manage searches in NetSuite with SuiteScript, utilizing filters, columns, and settings effectively.
- Filter Object Members for N/Search Module in NetSuite
Filter Object Members enhance search capabilities in NetSuite SuiteScript. Learn to create and configure filters effectively.
- Search for Sublist Line Fields With Dynamic Tables in NetSuite
Learn how to optimize search queries for sublist line fields in NetSuite using dynamic tables and SuiteQL.
- Error Handling in Searches with SuiteScript 2.0 Features
Gain insights into error handling in SuiteScript searches, including codes and common issues that arise when loading saved searches.
Advertising
Reach Searches Professionals
Put your product in front of NetSuite experts who work with Searches every day.
Sponsor This Category