Create a filter from a text value

poppinspoppins Member Posts: 647
Hi everyone,

I need to extract a filter value from a repeater and use it to filter on another record in order to print a report.
The user select one or more lines on the repeater.
I wrote the following code:

CLEAR(ltextFilter);
lrMyRec:=Rec;
CurrPage.SETSELECTIONFILTER(lrMyRec);
ltextFilter := SelectionFilterMgt.GetSelectionFilterForLocation(lrMyRec);
SalesHeader.SETFILTER("Location Code",ltextFilter);
DocPrint.PrintSalesOrder(SalesHeader,Usage::"Usage 1");



SelectionFilterMgt is standard codeunit 46.
I get the filter for location for example this way: 'Loc1|Loc2'.
The thing is that when the report request page is displayed, the filter in displayed Location Code field is litterally 'Loc1|Loc2'.
It should be just Loc1|Loc2
The report is trying to find a location with the exact code 'Loc1|Loc2' and finds nothing.

How shall I proceed with this?
Thanks in advance :)

Comments

  • SeeSharpSeeSharp Member Posts: 19
    As a guess, without firing NAV up.

    Would this not work?
    SalesHeader.SETFILTER("Location Code", DELCHR(ltextFilter, '=', ''''));
    
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    I tested with your code and Report is printing with Location filters correctly only.

    Where is the problem exactly?
  • vaprogvaprog Member Posts: 1,140
    edited 2015-11-03
    poppins wrote: »
    I get the filter for location for example this way: 'Loc1|Loc2'.

    please check again. Do you indeed receive 'Loc1|Loc2' or rather 'Loc1'|'Loc2'?

    The latter is, what SelectionFilterManagement used to return, using a rather simplistic quoting mechanism, quoting where no quotes are needed and not escaping embedded single quotes.

    Are you setting the filter exactly as you show in your code? setting it like
    SalesHeader.SETFILTER("Location Code",'%1',ltextFilter);
    
    will use the ltextFilter filter expression literally as value for the code field, and so will SETRANGE.
  • poppinspoppins Member Posts: 647
    edited 2015-11-04
    vaprog wrote: »
    poppins wrote: »
    I get the filter for location for example this way: 'Loc1|Loc2'.

    please check again. Do you indeed receive 'Loc1|Loc2' or rather 'Loc1'|'Loc2'?

    The latter is, what SelectionFilterManagement used to return, using a rather simplistic quoting mechanism, quoting where no quotes are needed and not escaping embedded single quotes.

    Are you setting the filter exactly as you show in your code? setting it like
    SalesHeader.SETFILTER("Location Code",'%1',ltextFilter);
    
    will use the ltextFilter filter expression literally as value for the code field, and so will SETRANGE.

    Yes you are right, it is indeed 'Loc1'|'Loc2'.
    and in my code:
    SalesHeader.SETFILTER("Location Code",ltextFilter);
    Is it correct? How can I get rid of the quotes?
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Why do you want to remove the quotes when report is working fine?
  • poppinspoppins Member Posts: 647
    Why do you want to remove the quotes when report is working fine?

    It is not working fine...
    Here is what I get in the request page:
    ywyir2zuwqp2.jpg

    So the result is a blank page...
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    why is it '201|301'?
    it should be '201'|'301'
Sign In or Register to comment.