Document number flow to report

NormajmNormajm Member Posts: 82
Hi All,

NAV 2015 here...
I made a copy of the purchase order report (10122) and put in our custom range, added it to the page 50/reports section and promoted it to Process. How do I get the document number to flow into the report automatically like it does on the original report. By that I mean, when I go to print the PO, it automatically picks up the PO number I'm on to print.

Thanks!

Answers

  • KishormKishorm Member Posts: 921
    Instead of using the RunObject property you need to run it via code, e.g. something like...
    PurchaseHeader2 := Rec;
    PurchaseHeader2.SETRECFILTER;
    REPORT.RUNMODAL(REPORT::"Your New PO Report",TRUE,FALSE,PurchaseHeader2);
    
    ...where PurchaseHeader2 is a local variable of type Record 38
  • NormajmNormajm Member Posts: 82
    I'm trying it with an Assembly Order Report and am getting an error...

    The variable is AssemblyOrderHdr2/Record/Assembly Header

    The code is placed in Assembly Header - OnAfterGetRecord() and is:
    AssemblyOrderHdr2 := "Assembly Header"."No.";
    AssemblyOrderHdr2.setrecfilter;
    report.runmodal (report::"Assembly Order Report", True, False, AssemblyOrderHdr2);

    The error is:
    The Record variable must belong to 900 and not to 0.
  • KishormKishorm Member Posts: 921
    You need to assign the record to your variable, not the assembly no., so it should be...
    AssemblyOrderHdr2 := "Assembly Header";
    
  • NormajmNormajm Member Posts: 82
    Thank you for the quick reply, no more error, but it isn't picking up the number...I've closed and reopened nav...
    f97fcb23ubcx.jpg

  • KishormKishorm Member Posts: 921
    You need to add the code to the OnPush() trigger of the action on the page - not to the OnAfterGetRecord() trigger of the report. The code should be something like this...
    AssemblyOrderHdr2 := Rec;
    AssemblyOrderHdr2.SETRECFILTER;
    REPORT.RUNMODAL(REPORT::"Assembly Order Report", True, False, AssemblyOrderHdr2);
    
  • NormajmNormajm Member Posts: 82
    Page 900/View Page Actions/F9

    I don't see an OnPush() trigger - Only <Actionxx> - OnAction()

    So I put the code into the "Print" action area - on this page it's Action 78, but it doesn't pull the correct record.

    Sorry - I'm new to this and I have a number of reports I'll need to do this with, once it's working.

    <Action78> - OnAction()
    //DocPrint.PrintAsmHeader(Rec);
    AssemblyOrderHdr2 := Rec;
    AssemblyOrderHdr2.SETRECFILTER;
    REPORT.RUNMODAL (REPORT::"Assembly Order Report", TRUE, FALSE, AssemblyOrderHdr2);
  • KishormKishorm Member Posts: 921
    edited 2016-12-19
    Yep, I meant OnAction() trigger - OnPush() is the old form based menubuttons

    The code you have shown above looks fine and should work.
  • NormajmNormajm Member Posts: 82
    No - unfortunately it doesn't - does it require a clear somewhere to clear the last entry?
  • NormajmNormajm Member Posts: 82
    This is the code I found on another page that works. However, I don't know how it was created because the SalesHdr and SOThankYou objects are not in the Global variables for that page.


    SalesHdr.SETRANGE("Document Type","Document Type");
    SalesHdr.SETRANGE("No.","No.");
    SOThankYou.SETTABLEVIEW(SalesHdr);
    SOThankYou.RUNMODAL;
  • KishormKishorm Member Posts: 921
    If they are not global variables then they will be local variables
  • NormajmNormajm Member Posts: 82
    C/AL Locals is greyed out. C/Al Globals/Functions/Locals/Variables - nothing there.
  • KishormKishorm Member Posts: 921
    Put your cursor on the code then look at View - Locals
  • NormajmNormajm Member Posts: 82
    Thank you for that - it was there! However, when I duplicated the code on the Assembly Order page, it still didn't work - dang. However, the clue may be here. When I run the report with the working code which is a report run against the Sales Header, note it is sorted and shows a filter of Document Type of Order. When I run the Assembly Order report, it does not show that. Could that be the next step in getting this to work?
Sign In or Register to comment.