Hi, Readers.
Today I would like to briefly talk about a qustion I saw in the Dynamics 365 Community yesterday, how to hide all comment lines in Standard Sales – Order Conf. (1305) report. It’s not that difficult.
As you might know, when you create a Sales Order in Business Central, on the Lines FastTab, in the Type field, select what type of product, charge, or transaction you post to the customer on the sales line.
All Sales Line Types:
More details: Enum “Sales Line Type”
You can leave the No. field empty if the line is for a:
- Comment. Write the comment in the Description field.
- Catalog item. Choose the Select Catalog Items action. Learn more at Dynamics 365 Business Central: Catalog Items and Work With Catalog Items. (Not the topic of this discussion)
In the Standard Sales – Order Conf. (1305) report, the Comment lines will also be printed.
Report Layout: Standard Sales Order Confirmation (Word)
Report Layout: Standard Sales Order Confirmation (RDLC)
However, this may be a small problem for some clients. They don’t want customers to see comments in the printed order. So is it possible to hide only the lines that are Comments? Yes, but this requires some simple customization.
We have discussed similar requirements before, but at that time it was a bit more complicated (More types need to be displayed, not less), more details: Dynamics 365 Business Central: How to print all type of lines in standard Pro Forma Invoice report – Customization
This time it’s simpler. Only two steps are needed.
1. Add a field on the request page to control whether to print comments
2. Add logic to the OnBeforePreDataItem or OnAfterPreDataItem trigger of Line dataitem.
That’s all, let’s do a simple test.
Show Comments: True
Show Comments: False
Test video:
Source code: Github (Please note that the source code is for reference only, you can improve it according to your own needs)
reportextension 50200 StandardSalesOrderConfExt extends "Standard Sales - Order Conf."
{
dataset
{
modify(Line)
{
trigger OnBeforePreDataItem()
begin
if not ShowComments then
Line.SetFilter(Type, '<>%1', Line.Type::" ");
end;
}
}
requestpage
{
layout
{
addafter(ArchiveDocument)
{
field(ShowComments; ShowComments)
{
ApplicationArea = All;
Caption = 'Show Comments';
}
}
}
}
var
ShowComments: Boolean;
}
Very simple, give it a try!!!😁
PS:
1. This method can also be used for other reports that use Line as Dataitem, such as Standard Sales – Invoice (1306)
Show Comments: True
Show Comments: False
Source code: Github (Please note that the source code is for reference only, you can improve it according to your own needs)
reportextension 50201 StandardSalesInvoiceExt extends "Standard Sales - Invoice"
{
dataset
{
modify(Line)
{
trigger OnBeforePreDataItem()
begin
if not ShowComments then
Line.SetFilter(Type, '<>%1', Line.Type::" ");
end;
}
}
requestpage
{
layout
{
addafter(DisplayAdditionalFeeNote)
{
field(ShowComments; ShowComments)
{
ApplicationArea = All;
Caption = 'Show Comments';
}
}
}
}
var
ShowComments: Boolean;
}
4. Dynamics 365 Business Central: How to add Media or MediaSet data type (Pictures) to a report
END
Hope this will help.
Thanks for reading.
ZHU
コメント