Hi All,
I'm still on my mission to get approvals working with additional block on printing, which I've done on the purchase order page. However I'm unsure how we can block documents from printing based on the document status on list page - as I'd assume you have to pass selected records from the list page and check. Bit tricky
Thanks
Well that's how you added the condition in your code, the Error Action will stop all the processing if you want to print only Released then you should remove Error and add a condition like this
iff PurchHeader.Status = PurchHeader.Status::Releaed then
PurchHeader.PrintRecords(true)
Problem is say in the above example if select 2 POs, first one Open and the second Released, and then hit Print, print action blocked on the Open PO and code exit. Released PO does not get to printed
Anita,
What is not working the print process ? Are you trying to print all the selected released orders ?
Thanks Tried it but still not working when you are selecting multiple records:
trigger OnAction()
var
PurchHeader: Record "Purchase Header";
begin
CurrPage.SETSELECTIONFILTER(PurchHeader);
if PurchHeader.FindSet() then
repeat
If PurchHeader.Status = PurchHeader.Status::Open then
Error('Order status open cannot be printed %1', PurchHeader."No." + FORMAT((PurchHeader.Status)))
// else
// PurchHeader.PrintRecords(true);
until PurchHeader.Next() = 0;
end;
You need to create a new variable, looks like you are using the Rec. Try this
action(PrintSelect) { ApplicationArea = Basic, Suite; Caption = 'Select Records'; Image = SelectEntries; Promoted = true; PromotedCategory = Process; trigger OnAction() var PurchHeader: Record "Purchase Header"; begin CurrPage.SetSelectionFilter(PurchHeader); if PurchHeader.FindSet then repeat Message(PurchHeader."No.") until PurchHeader.Next = 0; end; }
Thanks, Tried below code but it doesn't work when selecting multiple records for printing. For example below tries to block print when status is open. If I select 2 records when the first only open then loop exist after the first and doesn't print second which is say released:
begin
CurrPage.SETSELECTIONFILTER(Rec);
if rec.FindSet() then
repeat
If Rec.Status = Rec.Status::Open then
Error('Order status open cannot be printed %1', Rec."No." + FORMAT((Rec.Status)))
else
Rec.PrintRecords(true);
until Rec.Next() = 0;
end;
Other issue is after this runs on print action list page is filtered to selected. How do we show all records as before after the action?
Please search for setselectionfilter
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,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156