Filtering question

bangswitbangswit Member Posts: 265
how to filter more than 1?

how to change this code to be 1 variable??
SETFILTER("No.",'%1|%2|%3','ITEM05','ITEM06','ITEM07');

i made this, but failed
ItemText := 'ITEM05|ITEM06|ITEM07';
SETFILTER("No.",'%1',ItemText);

Comments

  • SPost29SPost29 Member Posts: 148
    I use this all the time

    POLine.SETFILTER("Document No.",POHdrFilter);

    Where POHdrFilter is 'PO1|PO2|PO3|PO4'

    I don't think you need the %1 in this usage.

    Steve
  • bangswitbangswit Member Posts: 265
    SPost29 wrote:
    I use this all the time

    POLine.SETFILTER("Document No.",POHdrFilter);

    Where POHdrFilter is 'PO1|PO2|PO3|PO4'

    I don't think you need the %1 in this usage.

    Steve
    thanks Steve
    by the way, do you know how to delete the latest character from variable?
    like this text --> 'PO1|PO2|PO3|PO4'
    it would be 'PO1|PO2|PO3|PO'
  • kitikkitik Member Posts: 230
    bangswit wrote:
    do you know how to delete the latest character from variable?
    like this text --> 'PO1|PO2|PO3|PO4'
    it would be 'PO1|PO2|PO3|PO'

    You can use function COPYSTR. Take a look at the help for details on how it works.

    Salut!
    Laura Nicolàs
    Laura Nicolàs
    Author of the book Implementing Dynamics NAV 2013
    Cursos Dynamics NAV (spanish) : http://clipdynamics.com/ - A new lesson released every day.
  • bangswitbangswit Member Posts: 265
    ok
    just like this
    COPYSTR(ItemVar,1,STRLEN(ItemVar)-1)

    thanks everyone
  • vaprogvaprog Member Posts: 1,139
    SPost29 wrote:
    I use this all the time
    POLine.SETFILTER("Document No.",POHdrFilter);
    Where POHdrFilter is 'PO1|PO2|PO3|PO4'

    I don't think you need the %1 in this usage.
    you don't only not need it, but it changes the logic.
    SETFILTER("No.",'%1','ITEM05|ITEM06|ITEM07');
    
    is not identical to
    SETFILTER("No.",STRSUBSTNO('%1','ITEM05|ITEM06|ITEM07'));
    
    but rather treats the 2nd Parameter as a filter and then, after it has parsed that filter, replaces any filter value that consists only of a "replacement field" (%1, %2 ...) with the corresponding value parameter.
    So in the example above, the filter string is parsed to consist of one single value (there are no filter operators in the string '%1'). Then the third parameter is used as that single value. The fact, that this value looks like a filter string is not taken into consideration.
Sign In or Register to comment.