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:
actions
{
modify("&Print")
{
Caption = 'PO Print';
trigger OnBeforeAction()
var
PurchaseHeader: Record "Purchase Header";
begin
IF PurchaseHeader.Status <> PurchaseHeader.Status::"Pending Approval" THEN Begin
PurchaseHeader := Rec;
CurrPage.SetSelectionFilter(PurchaseHeader);
PurchaseHeader.PrintRecords(true);
End
else
ERROR('Purchase order has not been approved');
end;