Pass parameter to report / Setrange two dataitems in report?

ellusiveladyellusivelady Member Posts: 23
edited 2008-06-22 in NAV Tips & Tricks
Scenario:-

Report: Sales Order
Data Items: Sales Header, Sales Line

In my Sales Order form, when I click Print Sales Order, above report will be previewed and printed.

This is the coding i use to just pass the Sales Order No. to my report.
SalesHeader.SETRANGE("No.","No.");
REPORT.RUN(REPORT::"Sales Order",TRUE,TRUE,SalesHeader);

I think you all know right that above coding will fill in the value of "No." under Sales Header tab in your request form.

NOW.. what i need is to pass another value "Type" for my dataitem Sales Line in the request form.

Help anyone? I hope my enquiry is explained to your understanding. Thanks.

Comments

  • SavatageSavatage Member Posts: 7,142
    SalesHeader.RESET;
    SalesHeader.SETRANGE("Document Type", "Document Type");
    SalesHeader.SETRANGE("No.","No.");
    REPORT.RUNMODAL(REPORT::"Sales Order",TRUE,TRUE,SalesHeader);

    Unlike the posted sales invoice table with a key of just "No."

    The sales Header Table needs two key
    doc type & no.

    Not sure I understand passing anything to the sales line table????

    if it's a finished report..hopefully the report is built correctly that it shows what you want it to.
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    Hi,
    NOW.. what i need is to pass another value "Type" for my dataitem Sales Line in the request form.

    If I understand correctly you want to print only a subset of sales invoice lines filtered by specific value of Type field ?

    If so - there is no straight method - you need to modify report and create some function to pass all necessary filters in some C/AL function call prior to running the report. You will also need to use another syntax to run your report (ReportXXX.RUN where ReportXXX is a variable of type of your report).

    Regards,
    Slawek
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • krikikriki Member, Moderator Posts: 9,094
    You can use a variable for your report. And then you can use the 2 tables, put the filters on them and give them to the report using:
    repSomeReport.SETTABLEVIEW(recSalesHeader);
    repSomeReport.SETTABLEVIEW(recSalesLine);
    
    The Navision-magic makes sure the filters go to the correct dataitem.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    kriki wrote:
    You can use a variable for your report. And then you can use the 2 tables, put the filters on them and give them to the report using:
    repSomeReport.SETTABLEVIEW(recSalesHeader);
    repSomeReport.SETTABLEVIEW(recSalesLine);
    
    The Navision-magic makes sure the filters go to the correct dataitem.
    :shock: :shock: :shock:
    =D>
    I didn't know - didn't even try such a solution even when needed something similar.

    This should go straight to Tips & Tricks.

    Regards,
    Slawek
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • krikikriki Member, Moderator Posts: 9,094
    This should go straight to Tips & Tricks.
    I should have thought about this! ](*,) ](*,) ](*,)

    [Topic moved from Navision forum to Navision Tips & Tricks forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.