Hi Everyone,
Am trying to post multi-selected documents that is in a customized module but if the first document has an error the posting is stopping and the loop doesn't go to the second document which has no error. If all the documents have no error everything is working perfectly. I want a situation where by if the first document has an error, the posting should continue up to the last document and for the ones that have errors, the errors should be queued or reserved and display as a message after the posting process exhaust all the documents. If no errors the message should be all documents posted successfully. How can I achieve that in AL? Below is the extract of my code
action(/Post Proposal/)
{
Caption = 'Post Proposal';
Image = Payment;
ToolTipML = ENU = 'Finalize the document or journal by posting the amounts and quantities to the related accounts in your company books.';
ApplicationArea = Basic;
Promoted = true;
PromotedIsBig = true;
PromotedCategory = Process;
PromotedOnly = true;
trigger OnAction()
var
Text001: label 'Are you sure you want to Post selected documents?';
Counter: Integer;
begin
Counter := 0;
if Confirm(Text001, false) then begin
CurrPage.SetSelectionFilter(Proposal);
if Proposal.FindSet() then
repeat
Counter += 1;
Rec.PostProposal(Proposal, false, Counter);
until Proposal.Next() = 0;
CurrPage.Update();
end;
end;