Get ID after using codeunit.run

_Midnight__Midnight_ Member Posts: 15
Hi guys!

Is it possible to call a codeunit with codeunit.run and then get the ID of the calling object, in the "OnRun" section?
I know there is a recordRef, but is there a objectref?


thanks!

Answers

  • matttraxmatttrax Member Posts: 2,309
    I'd consider doing it a different way. Setting your value in a function, then calling Codeunit.Run.

    Codeunit.SetCallingObject(objectID);
    Codeunit.RUN;

    Where Codeunit is a variable that refers to your Codeunit, not the CODEUNIT system variable.
  • _Midnight__Midnight_ Member Posts: 15
    thanks, but that's the way I did before.

    Thing is, we have to customize a lot of reports due implementation of a new software.
    The idea was, reducing customization by adding just one "codeunit.run"-line to each report.

    Looks like this will not work as we have to make var declaration and other steps.
    So, thanks anyway.
  • GRIZZLYGRIZZLY Member Posts: 127
    Based on blog of NAV team for logging report usage through the 1 CU, special trigger 120 (see http://blogs.msdn.com/b/nav/archive/2011/06/23/how-to-log-report-usage.aspx), I suggest you to modify that trigger and to call your codeunit, sending the report number (you've got ReportID as a variable in OnReportRun trigger in 1st CU).
    Hope you've got my idea!
    Sincerely yours, GRIZZLY
    Follow my blog at http://x-dynamics.blogspot.com
  • _Midnight__Midnight_ Member Posts: 15
    thanks grizzly!
    seems to be a good approach and I will give it a try!
Sign In or Register to comment.