This topic contains 5 replies, has 0 voices, and was last updated by kentroylance 7 years, 9 months ago.
-
AuthorPosts
-
February 16, 2017 at 2:33 pm #5944
kentroylanceI have the following filter that isn’t returning the right result:
filters[0] = new nlobjSearchFilter(‘internalid’, ‘contact’, ‘is’, input.id);
filters[1] = new nlobjSearchFilter(‘firstname’, null, ‘contains’, input.searchValue).setOr(true);
filters[2] = new nlobjSearchFilter(‘lastname’, null, ‘contains’, input.searchValue).setOr(true);
filters[3] = new nlobjSearchFilter(‘companyname’, null, ‘contains’, input.searchValue).setOr(true);
filters[4] = new nlobjSearchFilter(’email’, null, ‘contains’, input.searchValue).setOr(true);
filters[5] = new nlobjSearchFilter(‘entitystatus’, null, ‘anyof’, leadStatusCodes);
This is not working how I would want it where I really want:
filters[0] and (filters[1] or filters[2] or filters[3] or filters[4]) and filter[5]
Is there a better way to do this that works.
Thanks,
Kent
This is a cached copy. Click here to see the original post. -
February 16, 2017 at 2:57 pm #5945
MikeBucklaewHi Kent,
Can you build your search using the user interface to get the results you want? I’m a big fan of a tool that david.smith put together. https://usergroup.netsuite.com/users…pt-1-0-and-2-0 You create a saved search in the user interface and then it generates SuiteScript code for you based on that.
-
February 16, 2017 at 3:07 pm #5946
kentroylanceUnless I am missing something, I can’t see how to group a criteria with ands and ors within the tool.
david.smith replied on 02/16/2017, 03:42 PM: Within the UI you have to click the checkbox to USE EXPRESSIONS
-
February 16, 2017 at 3:41 pm #5947
david.smithI would highly suggest getting used to using the filter expressions. It’s just a set of arrays. I think what you’re looking for is something like this:
Code:
[
[‘contact.internalid’,’is’,input.id],
‘and’,
[
[‘firstname’,’contains’,input.searchValue],
‘or’,
[F2],
‘or’,
[F3],
‘or’,
[F4]
],
‘and’,
[‘entitystatus’,’anyof’,leadStatusCodes]
] -
February 16, 2017 at 4:02 pm #5948
kentroylanceFirst of all, thanks for your help. I cannot for the life of me figure this out.
I actually tried that, but I couldn’t get it to work. I took exactly what you have with a few modifications, and I am getting this error: Code: SSS_INVALID_SRCH_FILTER_EXPR_OBJ_TYPE Details: filters
var filters = [
[‘contact.internalid’, ‘is’, input.id],
‘and’,
[
[‘firstname’, ‘contains’, input.searchValue],
‘or’,
[‘lastname’, null, ‘contains’, input.searchValue],
‘or’,
[‘companyname’, null, ‘contains’, input.searchValue],
‘or’,
[’email’, null, ‘contains’, input.searchValue]
],
‘and’,
[‘entitystatus’, ‘anyof’, leadStatusCodes]
];
The output looks like this: contact.internalid,is,29998,and,firstname,contains ,mark,or,lastname,,contains,mark,or,companyname,,c ontains,mark,or,email,,contains,mark,and,entitysta tus,anyof,7,6
Thanks again for your help.
david.smith replied on 02/16/2017, 04:16 PM: Remove the “null” values from your arrays. The filter expressions use dot syn for the joins.
-
February 16, 2017 at 4:21 pm #5949
kentroylanceThat was the trick. Its the devil in the details that will get you every time. Thanks again for all your help.
-
AuthorPosts
You must be logged in to reply to this topic.