How do I generate a report in Dynamics NAV, with report copies having different names in the header

For example
1st Copy named Supplier Copy
2nd Copy named Customer Copy
3rd Copy named Records Copy
Best Regards,

We interact for the future of Code.

Best Answer

Answers

  • postsauravpostsaurav Member Posts: 708
    Hi,

    I would suggest to have a look on Report 405.
    The Copy are created Based on CopyLoop Data Item.

    On - OnAfterGetRecords of CopyLoop Data Item Look for Below Code -
    IF Number > 1 THEN
      CopyText := Text003;
    

    And Change it To -
    IF Number = 2 THEN
      CopyText := 'Supplier Copy';
    IF Number = 3 THEN
      CopyText := 'Customer Copy';
    IF Number = 4 THEN
      CopyText := 'Records Copy';
    
    

    Where 1 Will be Original Without any copy text.

    Thanks & Regards,
    Saurav Dhyani

    Do you Know this About NAV?


    Connect - Twitter | Facebook | Google + | YouTube

    Follow - Blog | Facebook Page | Google + Page
  • RwothoromoRwothoromo Member Posts: 10
    Thank you, let me retry that though it seemed to have failed earlier. I will get back to you.
    Best Regards,

    We interact for the future of Code.
  • RwothoromoRwothoromo Member Posts: 10
    I have compared Report Object Order 405 in NAV 2016 Object Designer and added the code as follows:

    IF Number > 1 THEN
    CopyText := Text003;
    IF Number > 2 THEN
    CopyText := 'Supplier Copy';
    IF Number > 3 THEN
    CopyText := 'Customer Copy';
    IF Number > 4 THEN
    CopyText := 'Book Copy';

    However, notably, Text003 is 'COPY'
    But still does not work.

    Was there any patch or work around you included.

    Thank you.
    Best Regards,

    We interact for the future of Code.
  • RwothoromoRwothoromo Member Posts: 10
    I have compared Report Object Order 405 in NAV 2016 Object Designer and added the code as follows:

    IF Number > 1 THEN
    CopyText := Text003;
    IF Number > 2 THEN
    CopyText := 'Supplier Copy';
    IF Number > 3 THEN
    CopyText := 'Customer Copy';
    IF Number > 4 THEN
    CopyText := 'Book Copy';

    However, notably, Text003 is 'COPY'
    But still does not work.

    Was there any patch or work around you included.

    Thank you.
    Best Regards,

    We interact for the future of Code.
  • RwothoromoRwothoromo Member Posts: 10
    The report is printed out without copies having their entitled names
    Best Regards,

    We interact for the future of Code.
  • RwothoromoRwothoromo Member Posts: 10
    edited 2016-01-04
    That helped, I just have to figure a work around the default =Code.GetData(18,1) on the Report Layout
    Best Regards,

    We interact for the future of Code.
  • RwothoromoRwothoromo Member Posts: 10
    Hi Saurav,
    By default, the Header name in Report 408 is decided by an expression =Code.GetData(1,3)
    But this exact expression does not work for custom reports.

    Did you face this and did you make a work around this?

    Thank you.
    Best Regards,

    We interact for the future of Code.
  • RwothoromoRwothoromo Member Posts: 10
    edited 2016-01-05
    Hi Saurav,
    By default, the Header name in Report 405 is decided by an expression =Code.GetData(18,1) But this exact expression does not work for custom reports.

    Did you face this and did you make a work around this?

    Thank you.
    Best Regards,

    We interact for the future of Code.
  • postsauravpostsaurav Member Posts: 708
    Hi,

    Two Things -
    1. I Told you the code as
    IF Number = 2 THEN
      CopyText := 'Supplier Copy';
    IF Number = 3 THEN
      CopyText := 'Customer Copy';
    IF Number = 4 THEN
      CopyText := 'Records Copy';
    

    ** Why you changed it To > insted of =. Anything >4 will also be greater that 1,2,3,4?

    2. Expression =Code.GetData(18,1), where GetData is a function mapped to a TextBox in Body of RDLC Report Named as PurchaseheaderDocumentType.

    The Text Box will be small one and will have Red Font.

    This Text Box have all fields which we need in Header, and the 18 number is mapped to one of the Names in Report Designer.

    The Data Source of the mapped name in Navision Designer will be - STRSUBSTNO(Text004,CopyText)

    Have a Look.

    Thanks & Regards,
    Saurav Dhyani

    Do you Know this About NAV?


    Connect - Twitter | Facebook | Google + | YouTube

    Follow - Blog | Facebook Page | Google + Page
  • RwothoromoRwothoromo Member Posts: 10
    edited 2016-01-06
    Thank you for the feedback guys.

    I solved the GetData problem.
    You have to select a TextBox in the Report Layout Body, Goto TextBox Properties, Visibility, Select Show or Hide Expression.

    Click on fx, and populate the expression for example:

    =Code.SetData(Cstr(Fields!ReportTitleText.Value) + Chr(177) +
    Cstr(Fields!BuyFromAddr1.Value) + Chr(177) +
    Cstr(Fields!SellToVendor.Value, 1)

    Where the 2nd parameter is Group Number and the 1st is the datasets.

    Then Goto the Textbox in the header where you want to GetData for example:

    =Code.GetData(1,1)

    //This Populates with changing value from Fields!ReportTitleText.Value

    Do likewise for Other Fields by Incrementing in order for example:

    =Code.GetData(2,1) //For Fields!BuyFromAddr1.Value
    =Code.GetData(3,1) //For Fields!SellToVendor.Value

    #Note that the Group Number 1 was set using SetData
    #Note that the Control Code for GetData and SetData is in the Report Layout Properties under the Code Tab. Edit Accordingly
    Best Regards,

    We interact for the future of Code.
  • let me add one more trick here: these textboxes where setdata functions are written unger Visibility expression is typically quite tricky to access, since they are small and placed under the main tablix...

    so what you might do if you are using Visual Studio is:
    open Solution Explorer window (ctrl+alt+l) -> right click on report.rdlc -> open with -> xml (text) editor -> use search and type setdata.

    Now you can see the Name of the textbox containing this functions and using this name you can come cack to layout editor (report.rdlc[Design]) and in Properties window find this textbox with the property Hidden containing code you are looking for. And actually it's even possible to make code adjustments in Report.rdlc editor:)
Sign In or Register to comment.