Hi, Readers.
Last week I was asked if it is possible to disable Print or Preview from a report in Business Central.
It’s an interesting question that sounds hard to do but is actually quite simple. First, you should know that the Print button and the Preview button can not be hidden. So what we need to do is to report the error after the user clicks Print or Preview.
This time we will use the following trigger and method.
OnPreReport Trigger: Runs before a report is run. (This trigger runs after the request page is run)
Report.Preview Method: Indicates whether a report is being printed in preview mode.
For example, let’s try to disable Preview from Standard Sales – Order Conf. (1305).
reportextension 50100 "Sales - Confirmation Preview" extends "Standard Sales - Order Conf."
{
trigger OnPreReport()
begin
if CurrReport.Preview then
Error('You can not preview this report.');
end;
}
Test video:
Next, let’s try to disable Print.
reportextension 50100 "Sales - Confirmation Preview" extends "Standard Sales - Order Conf."
{
trigger OnPreReport()
begin
if not CurrReport.Preview then
Error('You can not print this report.');
end;
}
Test Video:
Note: If you use “Not CurrReport.Preview” to disable print, The save as in Send to… will also not work.
Test video:
END
Hope this will help.
Thanks for reading.
ZHU
コメント