This topic contains 5 replies, has 0 voices, and was last updated by kentroylance 7 years, 6 months ago.

  • Author
    Posts
  • #21846 Score: 0

    kentroylance
    • Contributions: 0
    • Level 1

    I 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.

  • #21847 Score: 0

    MikeBucklaew
    • Contributions: 0
    • Level 1

    Hi 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.

  • #21848 Score: 0

    kentroylance
    • Contributions: 0
    • Level 1

    Unless 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

  • #21849 Score: 0

    david.smith
    • Contributions: 0
    • Level 1

    I 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]
    ]

  • #21850 Score: 0

    kentroylance
    • Contributions: 0
    • Level 1

    First 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.

  • #21851 Score: 0

    kentroylance
    • Contributions: 0
    • Level 1

    That was the trick. Its the devil in the details that will get you every time. Thanks again for all your help.

You must be logged in to reply to this topic.