Hi expert, if the shipping state is left blank, and when the user prints the sales order form, is there any way to prevent the printing (pops up error message (I know this) and then stop printing (not sure how)) till the user fills out the state. I understand it needs to add the trigger to the page, but if we do it from the report, is it possible and how? Thank you!
*This post is locked for comments
Sorry to reply late! Yes it is working now after adding the code to aftergetRecord(). Thank you experts!
Did you able to resolve this?
Instead of writing the IF statement, you can accomplish the same thing with less typing:
TESTFIELD("Ship-to County");
It works perfectly in my report.
Put following code in the OnAfterGetRecord() trigger in your report Sales Header dataitem
Hi expert, I tried, but it doesn't work.
I am using the following code:
IF "Sales Header"."Ship-to County"='' THEN
"Sales Header".TESTFIELD("Ship-to County");
Even though the user puts the value in the ship to county, the system still pops up the error and it blocks the printing.
Hi,
I recommend to use the TESTFIELD(Field Name) function in OnPreReport() in report to check that field must have some value so if it is blank then it will give error before printing.
-Saurabh Shah
Hey,
If you want to stop printing the report use following code in the Sales Header Dataitem in the report, onAfterGetRecord trigger
IF ShippingStatus ='' THEN
ERROR ('Shipping status should not be blank');
This will stop printing the report and if you have several orders this will halt them too, even if other orders have the shipping status.
If you want to just skip the records that does not meet your requirement then use following code in the Sales header Dataitem in the report, onAfterGetRecord trigger.
IF ShippingStatus ='' THEN
CurrReport.SKIP;
Or else you can set the filters to your dataitems in their property.
In the properties of the dataitem set the DataItemTableView to filter not empty values for the ShippingStatus.
Hello Snoppy,
If you wish to disable the user from printing the report from within the report, you can do it in several different ways.
If you wish to stop the printing completely, you could go to the Sales Header dataitem in the report, onaftergetrecord trigger and add a condition such as: IF (ShippingStateField='') THEN ERROR('The shipping state must have a value') (or use a TESTFIELD sentence).
If you do not want to stop the printing because the possibility of printing several sales orders is real and you do not want to stop the printing completely just because one record does not meet the requirement, you could use the CurrReport.SKIP function like this: IF (ShippingStateField='') THEN CurrReport.SKIP in the same trigger.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,219 Super User 2024 Season 2
Martin Dráb 230,056 Most Valuable Professional
nmaenpaa 101,156