web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Is it possible to capture Request Page Filters of a report through code

(0) ShareShare
ReportReport
Posted on by

Hi all,
I have created a report "GETILE" with DataItem "Item Ledger Entry" and selected SaveValues = yes to get filters for the next run.

I have an action "Check Page Filters" in Item List Page and when i run this it opens list of Item Ledger Entries .

I will apply some filters to the page and select couple of lines from the ILE List and pass this value to run "GETILE" report. Automatically it filters the selected lines data and runs the report. 

When i click the "Check Page Filters" from Item List Page again , is it possible to copy the previously applied report filters(applied SaveValues = Yes) into Item Ledger Entry Variable ?

Regards,

Murali 

*This post is locked for comments

I have the same question (0)
  • Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    Without see the code is difficult, but maybe you can use GETFILTERS function to retrieve the filters as a string and then apply them to your dataitem.

  • Suggested answer
    keoma Profile Picture
    32,729 on at

    save the filters (text string) in a table field.

  • Community Member Profile Picture
    on at

    Hi Archer,

    Thanks for the reply.

    I tried to copy the filters as Text field in ILE table. But how can I apply them as filters on ILE Table.

    Now i have Text value as : "Marked: Yes , Item No. :1000,Entry Type: Purchase".(filters which i applied from Item List Page to run ILE Page)

    with this value how can i filter the ILE Table ?

    Regards,

    Murali

  • Verified answer
    keoma Profile Picture
    32,729 on at

    you could try this:

    OnRun()

    //loc. var.

    //ile Record Item Ledger Entry

    ConvertFilters('Marked: Yes, Item No.: 1000, Entry Type: Purchase',ile);

    MESSAGE(ile.GETFILTERS);

    PAGE.RUN(0,ile);

    LOCAL ConvertFilters(savedFilters : Text;VAR ile : Record "Item Ledger Entry")

    // loc. vars

    //recref RecordRef

    //recid RecordID

    //i Integer

    //filter Text

    //fieldName Text

    //value Text

    //fieldNo Integer

    //fref FieldRef

    //filterMarked Boolean

    recid := ile.RECORDID;

    recref := recid.GETRECORD;

    i := 1;

    WHILE i < 4 DO BEGIN

     filter := SELECTSTR(i,savedFilters);

     filter := CONVERTSTR(filter,':',',');

     fieldName := SELECTSTR(1,filter);

     fieldName := DELCHR(fieldName,'<>',' ');

     value := SELECTSTR(2,filter);

     value := DELCHR(value,'<>',' ');

     IF fieldName = 'Marked' THEN

       filterMarked := TRUE

     ELSE BEGIN

       fieldNo := GetFieldNo(fieldName,recref);

       fref := recref.FIELD(fieldNo);

       fref.SETFILTER(value);

     END;

     i += 1;

    END;

    // copy filters from recref to table ILE (won't work without that line)

    ile.SETVIEW(recref.GETVIEW);

    IF filterMarked THEN

     ile.MARKEDONLY := TRUE;

    LOCAL GetFieldNo(fieldName : Text;recref : RecordRef) fieldNo : Integer

    FOR fieldNo := 1 TO recref.FIELDCOUNT DO BEGIN

     IF recref.FIELDEXIST(fieldNo) THEN

       IF recref.FIELD(fieldNo).NAME = fieldName THEN

         EXIT;

    END;

    EXIT(0);

  • Suggested answer
    Community Member Profile Picture
    on at

    Hello,

    Check the example below:

    ItemLedgerEntry.SETFILTER("Item No.", GETFILTER("No."));
    ItemLedgerEntry.SETRANGE(Description, 'Bla Bla Bla');
    
    TempXml := '<?xml version="1.0" standalone="yes"?>'
              +'<ReportParameters name="ILE" id="50000">'
              +    '<Options>'
              +        '<Field name="DummyOption">true</Field>'
              +    '</Options>'
              +    '<DataItems>'
              +        '<DataItem name="Item Ledger Entry">' + ItemLedgerEntry.GETVIEW(FALSE) + '</DataItem>'
              +    '</DataItems>'
              +'</ReportParameters>';
    
    TempXml := MyReport.RUNREQUESTPAGE(TempXml);
    MESSAGE(TempXml);


    RUNREQUESTPAGE_5F00_Example.txt

  • Community Member Profile Picture
    on at

    Hi Jonathan,

    Thank you so much for the help. This is what i was expecting and it is working perfectly fine.

    I just got some error in GetfieldNo. Funciton and I replaced that function with following code .

         CLEAR(lrec_Field);

         lField.SETCURRENTKEY(TableNo,"No.");

         lField.SETRANGE(TableNo, RecRef.NUMBER);

         lField.SETRANGE(FieldName,FieldName);

         IF NOT lField.FINDFIRST THEN

           EXIT(0);

         EXIT(lField."No.");

    Thank you agian.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans