Monday, May 20, 2019

List of Sales order Status as Search Filter value using SuiteScript

The List of Sales order status depends on the available features in their NetSuite Account. Users can use saved search and getFilterExpression() to get the List of order status. This can be use when searching sales order record through SuiteScript.

First, create a Saved search:
1. Navigate to List > Search > Saved Searches > New
2. Click on Transaction
3. Go to Criteria > Standard
  Enter the folowing: 
   -Add Status as fillter
    -Select Any Of
      -Add the following:
       -Sales Order:Pending Approval
       -Sales Order:Pending Fulfillment
       -Sales Order:Cancelled
       -Sales Order:Partially Fulfilled
       -Sales Order:Pending Billing/Partially Fulfilled
       -Sales Order:Pending Billing
       -Sales Order:Billed
       -Sales Order:Closed
3. Save

User can run the script below using NetSuite Debugger(Customization > Scripting > Script Debugger):

var salesorderSearch = nlapiLoadSearch('transaction', 89); //internalId of the saved search
var soSearchExp = salesorderSearch.getFilterExpression();

soSearchExp returns the statuses below: (Note: The status values returned are subject to change.)
soSearchExp = {array} length=1
[0] = {array} length=10
[0] = {string} status
[1] = {string} anyof
[2] = {string} <status value>
[3] = {string} <status value>

Example of Search filters with Sales order status:

new nlobjSearchFilter('status', null, 'anyOf', '<status value from above>')

No comments:

Post a Comment