Skip links
Dr NetSuite

Dr. NetSuite: SuiteScript 2.0 Nested Conditions

Dr. NetSuite:  SuiteScript 2.0 Nested Conditions

 

Search filters for empty value in nested conditions in SuiteScript 2.0

While trying to filter a search for some project tasks using a custom fields in SuiteScript 2.0, I got hit by a frustrating issue. I could not nest the conditions like this; ConditionA AND ConditionB AND (ConditionC OR ConditionD ). SuiteScript kept throwing the error: “WRONG_PARAMETER_TYPE”.

Using filter expression syntax it looked like this:

[[“startdate”,”before”,”1/2/2017″],”AND”,[“job.custentity_project_ship”,”anyof”,”1″],”AND”,[“custevent_scope_discipline”,”anyof”,”1″],”AND”,[[“custevent_supervisor_perc”,”lessthan”,100],”OR”,[“custevent_supervisor_perc”,”isempty”]]]

The issue was in the last condition; [“custevent_supervisor_perc”,”isempty”]. For some reason SuiteScript 2.0 wrapper does not allow that syntax.

NetSuite support suggested using the following [‘description’,’is’,’@NONE@’], but this had the effect of making the search ignore the OR group.

I finally got it working by passing @NONE@ to “isempty” operator like so: [‘custevent_supervisor_perc’, search.Operator.ISEMPTY, ‘@NONE’]

Not very logical but it is now working.

 

Written by Dr. NetSuite at Cofficient Ltd – Issuing Suite cures for all your NetSuite ailments.