It is annoying to change the report layouts according to customer requirements, because every time developer needs to open the design view and then go to layout in the Visual Studio.
3. Following is the report we are going to modify.
4. Run the report and see the output of the report before do the modification.
5. Create a code unit and in that create a function called “Format Field”
7. Go to parameter tab and define 3 input variables with the data types define below.
- ReportID_In – Integer
- FieldName_In – Integer
- Value_In – Text 100
9. Go to Format Field in the code unit and write the following code
Format Field(ReportID_In : Integer;FieldName_In : Text;Value_In : Text) ReturnValue : Text
IF recReportFormatting.FINDFIRST THEN BEGIN
ReturnValue := '<html><font size =';
ReturnValue := ReturnValue + recReportFormatting."Font Size" + ' color =' + recReportFormatting."Font Color" + '>';
ReturnValue := ReturnValue + ' ' + Value_In;
ReturnValue := ReturnValue + '</font></html>';
END ELSE BEGIN
ReturnValue := Value_In;
10. Compile and save the code unit and you are done with most of the coding necessary.
Now lets move to the next part of the development. Which is the easy part.
11. Go to the report and go to the design view of it.
12. Then click on the “Cust. Ledger Entry” data item and go to the code of the trigger.
We are going to modify the customer name according to the parameters set in the earlier defined table.
In this report we need to do few more modifications. We are going to write the coding in the highlighted area and before that we need to define few more variables.
13. Define following variables as globe variables in the report.
- cduReportFormat – Codeunit – Report Formatting (50000)
- textname – Text 100
- ReportID – Integer
- CustomerName – Text 50
- CusNameForReport – Text 100
14. Write the following code in the report where I have highlighted before.
This will pass the report ID and Value to the function we defined early and will return a HTML tag text.
2: CustomerName := CustAddr;
3: CusNameForReport := cduReportFormat."Format Field"(ReportID,'Customer Name',CustomerName);
15. Go to design view of the report (dataitem) and add the following variable to the report data set.
16. Then open the report in Report Layout mode and as you can see there are various text boxes with different values. We are going to change the format of the customer name column. Therefore we do not need the existing column. Just delete the first text box in the upper left corner.
17. Now we need a new data holder to add the customer name, and that place holder should be able to read and format our HTML string. Can we do that easily or do we have to modify lot of things? No we don’t!
Just add a text box and double click on it and then right click.
Then click on the “Create Placeholder“
18. In the Placeholder property window click on the HTML- Interprete HTML tags as styles radio button.
This will tell the placeholder to read the HTML tags and convert them to the styles.
Happy testing guys!!
Thank you and Regards,
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?