Wednesday, April 24, 2019

SuiteScript: Filter expressions are malformed when using getFilterExpression and operator "isempty" or "isnotempty"

When loading existing criteria from saved search using getFilterExpression unexpected error is thrown if isempty or isnotempty operators are used as criteria and are passed as parameter to function setFilterExpression.

This is documented in Defect 244249.


Steps to reproduce:

  1. Lists > Relationships > Vendor > Search
    ID: customsearch_test
    Criteria: Comments is empty
       OR
    Comments is not empty
    Save
  2. Log into debugger
  3. Run script attached below

Actual Result:
Unexpected error is thrown.

Expected result:
No error is shown; whole filter expression is cloned to new search.

Script:

var search = nlapiLoadSearch('vendor', 'customsearch_test');var filterExpr = search.getFilterExpression();var search2 = nlapiCreateSearch('vendor');search2.setFilterExpression(filterExpr);var debugger_placeholder = 0;

Solution:

Construct filter expression manually with third element "null" in array as following:

var filterExpr = [ ["notes", "isempty", null], "OR", ["notes", "isnotempty", null] ];

No comments:

Post a Comment