Hi All,
I'm trying to stop un-approved purchase order from being printed via code. And tried below code but doesn't seem to work:
Hi All,
I'm trying to stop un-approved purchase order from being printed via code. And tried below code but doesn't seem to work:
This worked:
begin
PurchaseHeader := Rec;
IF PurchaseHeader.Status = PurchaseHeader.Status::"Pending Approval" THEN
ERROR('Purchase order has not been approved')
else
CurrPage.SetSelectionFilter(PurchaseHeader);
PurchaseHeader.PrintRecords(true);
It’s the placement of the error that might need changing. The selectionfilter is fine for the print command. I think you should do a if findset on the filter criteria before doing the print. The selection filter will have many records to loop through so the error command in isolation probably doesn’t pick up on that. There are more sophisticated error trapping methods if passed to a relevant codeunit
Hi,
For which page have you written this code. Look like you have written it for List page. What is the problem you are getting. Can you elaborate?
André Arnaud de Cal...
292,999
Super User 2025 Season 1
Martin Dráb
231,831
Most Valuable Professional
nmaenpaa
101,156
Moderator