Category Archives: programming - Page 2

How to Define SetData and GetData in RTC Reports in Dynamics NAV Navision

For some reason unfamiliar to me, Microsoft likes to write tutorials that does not easily teach you what you need to do to get the job done.

For basic List type reports, yes, it’s quick and simple, however, when it comes to reports involving forms (i.e. sales order, sales invoice, etc), I cannot find a good tutorial on how to get it done.

Forget about the Create Layout Suggestion feature on the form type reports. It sucks. You’d save a lot more time by re-creating your layouts in the standard NAV RDLC report.

One of the most important aspects of the Form type report when you’re trying to edit the standard report is 2 functions: SetData and GetData.

In this example, I’m modifying report 5703 (Transfer Order) report. I’m going to add the Shipment Date and the Shipment Method Code to the report in the report.

Here’s what you need to do, step by step:

1. Create the fields in the classic report and point to the proper field. It doesn’t matter where you put it as we’re not displaying the classic report.
Pic1

2. Click on View –> Layout. This is to modify the report when running the report in the RTC environment. Note that you’ll need Visual Studio 2005 and above to do this.
Pic2

3. You want to add 4 additional text boxes. Two for the caption box and 2 for the text box. I just copy and paste from the existing text boxes above. Number your GetData function 21 to 24 as shown in the example.

Background and the reason for this, if you’re not interested, skip to #4:
Now you need to do a little detective work to find where the SetData and the GetData is. If you notice on the upper left corner, there’s a small hidden field in red. If you highlight the field, the code reads:
Pic3

What’s the reason behind using SetData and GetData? The reason is because you cannot add field text boxes in the report header. The argument here is performance. If you like to read, there’s a section in the 80146B manual that you can download from Customersource or Partnersource. So most of the coding is done on the lines area.

Now, back to the tutorial, where to set the SetData and GetData? Here’s where you need to play a little detective.

4. On the lower right corner, there are some additional hidden boxes in red. Highlight each one of them until you find this one (Note the HeaderInfo. It corresponds to the SetData).
Pic4

5. Highlight the text box and go to the Value property. Click on the Property Page icon to display the property of the Value:�
Pic5

6. Go to the General tab and click on the fx button next to the Value
Pic6

7. Type in the 4 additional fields you’ve set from row 21-24.
Pic7

8. Click OK and close and save the report

9. Go back to the RTC and run the Transfer Order report:
Pic8

There you have it. Seems like an awful lot of steps for something so simple… But this is supposed to make our life easier so we’ll walk along and wait for the benefits to come.

How to Create Drilldown page to a custom table in RTC – NAV2009 SP1

This is so someone does not pull their hair out like I just did. I cannot find anywhere in the documentation where this is explained so here it is:

1. Create your custom table
2. Create the drilldown page with SourceTable to your custom table
3. Save the page and REMEMBER THE ID
4. Go to the table property on the table you created in step 1
5. TYPE IN the Page ID in the DrillDownFormID property in step 4
6. Save and test your work.

In the table designer, there’s no place to specify the Drilldown Page. So you will need to use the DrillDownFormID property on the table even though there’s no forms created. 

<Posted edited, thanks to a3arn for confirm that you do not need to create a form>

If you look through the standard objects, you’ll notice that the drilldown FORMS have the same ID as the drilldown PAGES. Tricky….

How to Calculate the Current Fiscal Year

In Navision, there’s no function that will give you the fiscal year according to what you’ve setup on the Accounting Period table. Here’s a code that will get the current fiscal year based on the accounting period:

AccountingPeriod is a record variable  to table 50
Date1 and Date2 are date variables

AccountingPeriod.RESET;
AccountingPeriod.SETRANGE(“New Fiscal Year”,TRUE);
AccountingPeriod.”Starting Date” := WORKDATE;
AccountingPeriod.FIND(‘=<‘);
Date1 := AccountingPeriod.”Starting Date”;
IF AccountingPeriod.NEXT = 0 THEN
  Date2 := 12319999D
ELSE
  Date2 := AccountingPeriod.”Starting Date” – 1;