SETFILTER Question

SbhatSbhat Member Posts: 301
Hi Folks -

I have a SETFILTER question.

On the Vendor card i have a field called 'Responsibility center' which has values like NY,ATLANTA,DC,CANADA and some vendors have blank responsibility center, when user opens the vendor card i want to see all vendors that have blank responsibility center plus vendors with responsibility center with NY,ATLANTA and DC. I stored the the 3 responsibility center in a string called
temp := 'NY|ATLANTA|DC'

I then tried vendrec.SETFILTER("responsibility center",'%1&%2',' ',temp) but does not work.

Is there any way to show the blank vendors plus the one in the temp string.

Any help is appreciated !

Thanks
SB.

Comments

  • matttraxmatttrax Member Posts: 2,309
    NAV evaluates exactly what you type in.

    So you can't have something that is equal to DC, ATLANTA, or NY and also equal to blank at the same time.

    You want DC|ATLANTA|NY|''
  • SbhatSbhat Member Posts: 301
    I tried placing |'' and it still does not work. Any thoughts.
  • matttraxmatttrax Member Posts: 2,309
    What's your exact filter string now?
  • navinbnavinb Member Posts: 51
    Hi,

    I think you have want to exclude only canada,it can be like this then :

    vendrec.SETFILTER("responsibility center",'<>%1','CANADA);


    -
    Navin
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    Sbhat wrote:
    temp := 'NY|ATLANTA|DC'

    I then tried vendrec.SETFILTER("responsibility center",'%1&%2',' ',temp) but does not work.

    1. as mattrax said you cannot have something equal to some text AND equal to blank at the same time

    2. SETFILTER(field,'%1', string) filters for EXACT string variable content, in your case 'NY|ATLANTA|DC'. The string variable is not interpreted as filter syntax, it is quoted because you have used '%1 in SETFILTER syntax.

    In order to make this work as expected you need to use SETFILTER(field, string) syntax.

    If you want to add empty Responsibility Centre you should add it to your temp variable, like this:
    temp := '''''|NY|ATLANTA|DC'
    and use
    SETFILTER("responsibility center",temp);
    Note one ' string opening character plus four ' characters to include empty string in the filter - NAV will understand this as ''|NY|ATLANTA|DC filter. Use MESSAGE(temp) to test what NAV will see.

    Hope this helps,
    Slawek
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • kinekine Member Posts: 12,562
    Or you can use this:
    temp := 'NY|ATLANTA|DC'

    I then tried vendrec.SETFILTER("responsibility center",temp+'|%1',' ');
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.