microsoft / ALAppExtensions

Repository for collaboration on Microsoft AL application add-on and localization extensions for Microsoft Dynamics 365 Business Central.
MIT License
768 stars 610 forks source link

[EVENT REQUEST] Report 511 "Complete IC Inbox Action" #26937

Open Ilke415 opened 1 month ago

Ilke415 commented 1 month ago

Describe the request

Hi, we need additional event in the report 511 "Complete IC Inbox Action" in order to keep Inbox Transaction without showing the error to the user if insert of Handled Inbox Transaction fails.

Additional context

            trigger OnAfterGetRecord()
            var
                InboxTransaction2: Record "IC Inbox Transaction";
                HandledInboxTransaction2: Record "Handled IC Inbox Trans.";
                ICCommentLine: Record "IC Comment Line";
                ICPartner: Record "IC Partner";
// Start
                IsRecordInserted: Boolean;
                SkipRecord: Boolean;
// End
            begin
                if "Line Action" = "Line Action"::"No Action" then
                    CurrReport.Skip();
                InboxTransaction2 := "IC Inbox Transaction";
                if ("Source Type" = "Source Type"::Journal) and
                   (InboxTransaction2."Line Action" <> InboxTransaction2."Line Action"::Cancel) and
                   (InboxTransaction2."Line Action" <> InboxTransaction2."Line Action"::"Return to IC Partner")
                then begin
                    TempGenJnlLine.TestField("Journal Template Name");
                    TempGenJnlLine.TestField("Journal Batch Name");
                end;
                if (InboxTransaction2."Line Action" <> InboxTransaction2."Line Action"::Cancel) and
                   ICPartner.Get(InboxTransaction2."IC Partner Code")
                then
                    ICPartner.TestField(Blocked, false);
                HandledInboxTransaction2.TransferFields(InboxTransaction2);
                case InboxTransaction2."Line Action" of
                    InboxTransaction2."Line Action"::Accept:
                        HandledInboxTransaction2.Status := HandledInboxTransaction2.Status::Accepted;
                    InboxTransaction2."Line Action"::"Return to IC Partner":
                        HandledInboxTransaction2.Status := HandledInboxTransaction2.Status::"Returned to IC Partner";
                    InboxTransaction2."Line Action"::Cancel:
                        HandledInboxTransaction2.Status := HandledInboxTransaction2.Status::Cancelled;
                end;
                OnBeforeHandledInboxTransactionInsert(HandledInboxTransaction2, InboxTransaction2);
// Start
                IsRecordInserted := HandledInboxTransaction2.Insert();
                OnAfterHandledInboxTransactionInsert(HandledInboxTransaction2, InboxTransaction2, IsRecordInserted, SkipRecord);

                if SkipRecord then
                    CurrReport.Skip();

                if not IsRecordInserted then
// End
                    Error(
                      Text001, InboxTransaction2.FieldCaption("Transaction No."),
                      InboxTransaction2."Transaction No.", InboxTransaction2."IC Partner Code",
                      HandledInboxTransaction2.TableCaption());
                InboxTransaction2.Delete();

                ICIOMgt.HandleICComments(ICCommentLine."Table Name"::"IC Inbox Transaction",
                  ICCommentLine."Table Name"::"Handled IC Inbox Transaction", "Transaction No.",
                  "IC Partner Code", "Transaction Source");

                Forward := false;
            end;
...

// Start
    [IntegrationEvent(false, false)]
    local procedure OnAfterHandledInboxTransactionInsert(var HandledICInboxTrans: Record "Handled IC Inbox Trans."; var InboxTransaction: Record "IC Inbox Transaction"; IsRecordInserted: Boolean; var SkipRecord: Boolean)
    begin
    end;
// End

Internal work item: AB#543332

azure-boards[bot] commented 1 month ago

✅ Successfully linked to Azure Boards work item(s):