Question

How can i write a function to update record in Microsoft Dynamic NAV using Role Tailored Client Report ?

Thx in advance, Makara

Was it helpful?

Solution

You cannot place C/AL code directly on RTC Reports -- instead you should use the triggers behind DataItems in the 'Classic' client/Development Environment, as this code is common to both Classic and RTC reports, and executed when the report is run in either environment.

To use a similar example;

Vendor - OnAfterGetRecord()
----------------------------

...

IF Vendor."Phone No." = '' THEN BEGIN
  Vendor."Phone No." := NewPhoneNo;
  Vendor.MODIFY;
END;

...

You may want to set the following properties on the report itself to hide the print dialog, as well as the request form (assuming you don't want filters applied):

UseReqForm := FALSE;
ProcessingOnly := TRUE;

Another important thing to note is that code sitting behind sections is only used for Classic reports and won't be executed if running in the RTC (which may explain unexpected results).

OTHER TIPS

You can place code in your report triggers.

Below is a simple example of code that can be put in the OnAfterGetRecord trigger of a Customer data item that refers to the Customer table.

IF Customer.Name[1] = 'A' THEN BEGIN
  Customer.Name[1] := 'B';
  Customer.MODIFY;
END

The code above changes the first character of the name of any customer included in the report that begins with an upper case 'A' to an upper case 'B'.

A complete report with just this functionality and no printout can be found from pastebin: Simple Dynamics Nav Report Sample.

You can copy the entire content of the paste into a text file and import it into Nav as text.

Beware, however that doing this will replace any previous report with the id of 50000 with this example without any additional warning or prompt. The report imported as text will need to be saved in compiled form in Nav prior to you being able to run it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top