PathSelector Object Members in SuiteScript for Data Filtering

PathSelector object members facilitate the creation of filters, sorts, and selections in SuiteScript for efficient data management.

·2 min read·View Oracle Docs

The PathSelector object in SuiteScript is an essential component for developers aiming to create sorting definitions or filters within workbooks. This object allows you to specify criteria for viewing and managing data effectively, critical for advanced data manipulation tasks in SuiteScript.

What is the PathSelector Object?

The PathSelector object is designed to be utilized in methods such as workbook.createConditionalFilter(options), workbook.createLimitingFilter(options), workbook.createSortDefinition(options), and workbook.createSortByMeasure(options). It simplifies data interactions by providing a pathway for developers to define how data is filtered or sorted.

PathSelector Object Members

The following member is available for a workbook.PathSelector object:

Field NameTypeDescription
elementsworkbook.DimensionSelectorRepresents the elements denoting 'xpath' of the selector.

Supported Script Types: This object is primarily used in server scripts, making it crucial for backend operations within the NetSuite environment.

How to Create a PathSelector

To instantiate a PathSelector, use the workbook.createPathSelector(options) method. Below are examples of how this can be implemented:

suitescript
1// Create an AllSubNodesSelector PathSelector
2var myPathSelector = workbook.createPathSelector({
3 elements: [workbook.createAllSubNodesSelector()]
4});
5
6// Create a DimensionSelector PathSelector
7var myPathSelector = workbook.createPathSelector({
8 elements: [myDimensionSelector]
9});

Usage in Workbook Definitions

The PathSelector is also utilized when loading workbook data. Below is a sample code snippet demonstrating how to access the PathSelector elements in a pivot definition:

suitescript
1var myWorkbook = workbook.load({
2 id: myWorkbookId
3});
4
5var myPathSelector = myWorkbook.pivots[0].aggregationFilters[0].filteredNodesSelector.elements;
6log.audit({
7 title: 'PathSelector.elements = ',
8 details: myPathSelector.elements
9});

Important Notes

  • The elements member must return a value of type workbook.DimensionSelector. If an incorrect type is supplied, the code will throw a WRONG_PARAMETER_TYPE error.

Good Practices: Always ensure that the types of members in your PathSelector are correctly specified to avoid runtime errors, and utilize the built-in logging functionality to aid in debugging.

Who This Affects

  • Developers: Those creating and managing scripts using SuiteScript.

Key Takeaways

  • The PathSelector object simplifies the development of sort definitions and filters in SuiteScript.
  • Key member is the elements, which requires a specific type for successful execution.
  • Use the PathSelector in conjunction with other workbook methods for enhanced data management capabilities.

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

Frequently Asked Questions (4)

Is the PathSelector object available for use in client scripts in SuiteScript?
No, the PathSelector object is primarily used in server scripts, which are essential for backend operations within the NetSuite environment.
What error might occur if an incorrect type is specified for the elements in a PathSelector?
Supplying an incorrect type for the elements in a PathSelector will result in a WRONG_PARAMETER_TYPE error.
How is the PathSelector utilized within workbook operations?
The PathSelector is used in methods like workbook.createConditionalFilter, workbook.createLimitingFilter, workbook.createSortDefinition, and workbook.createSortByMeasure to define how data is filtered or sorted.
What is a practical use-case of the PathSelector elements in a pivot definition?
In a pivot definition, PathSelector elements can be accessed to filter nodes in workbook aggregation filters, as demonstrated in the provided script snippet that logs elements of a filteredNodesSelector.
Source: PathSelector Object Members 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 Platform

View all Platform articles →