Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EVENT REQUEST] Report 511 "Complete IC Inbox Action" in OnAfterGetRecord of "IC Inbox Purchase Header" #27912

Open
KaMu0608 opened this issue Jan 9, 2025 · 0 comments

Comments

@KaMu0608
Copy link

KaMu0608 commented Jan 9, 2025

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.

        ```
            trigger OnAfterGetRecord()
            var
                InboxTransaction2: Record "IC Inbox Transaction";
                HandledInboxTransaction2: Record "Handled IC Inbox Trans.";
                ICCommentLine: Record "IC Comment Line";
                ICPartner: Record "IC Partner";
                IsHandled: Boolean;
// 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;
                IsHandled := false;
                OnBeforeHandledInboxTransactionInsert(HandledInboxTransaction2, InboxTransaction2, IsHandled);            
// Start
                IsRecordInserted := HandledInboxTransaction2.Insert();
                OnAfterHandledInboxTransactionInsert(HandledInboxTransaction2, InboxTransaction2, IsRecordInserted, SkipRecord);

                if SkipRecord then
                    CurrReport.Skip();

                if not IsRecordInserted and (not IsHandled) then
               //if not HandledInboxTransaction2.Insert() and (not IsHandled) then //-> deleted
// 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

### Additional context

If HandledInboxTransaction2.Insert() fails, 
we want to keep InboxTransaction2 without showing the error to the user, 
but want to continue, that is why we need the CurrReport.Skip.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant