web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

How to bypass "Auto. Accept Transactions" when posting Intercompany Journals via AL Code

(5) ShareShare
ReportReport
Posted on by 149
Hi All,
 
In Business Central, when an Intercompany Journal is posted, the system checks the "Auto. Accept Transactions" setting on the IC Partner card. If this flag is enabled, the transactions are automatically accepted into the partner company’s inbox. I want to bypass this via AL Code.
 
 
Problem Statement -

In my scenario, I want to bypass this behavior — meaning the transactions should be sent to the IC Inbox, and gets automatically accepted, regardless of whether the partner’s "Auto. Accept Transactions" setting is enabled or not. I need this to work on one IC Journal Template and Batch only.

Has anyone implemented a solution or customization to override this logic in the Partner Company?

Also, I have already traversed the whole IC Journal Posting, and I got to see that this is checked in the codeunit 790 - "IC Inbox Outbox Subscribers", but there is no IsHandled variable for skipping this part for me.

[EventSubscriber(ObjectType::Report, Report::"Move IC Trans. to Partner Comp", 'OnICInboxTransactionCreated', '', false, false)]
    local procedure AcceptOnAfterInsertICInboxTransaction(var Sender: Report "Move IC Trans. to Partner Comp"; var ICInboxTransaction: Record "IC Inbox Transaction"; PartnerCompanyName: Text)
    var
        ICPartner: Record "IC Partner";
        TempRegisteredPartner: Record "IC Partner" temporary;
        FeatureTelemetry: Codeunit "Feature Telemetry";
        ICMapping: Codeunit "IC Mapping";
        ICDataExchange: Interface "IC Data Exchange";
    begin
        ICPartner.SetRange("Inbox Details", PartnerCompanyName);
        if not ICPartner.FindFirst() then
            exit;

        ICDataExchange := ICPartner."Data Exchange Type";
        ICDataExchange.GetICPartnerFromICPartner(ICPartner, TempRegisteredPartner);

        FeatureTelemetry.LogUptake('0000IIX', ICMapping.GetFeatureTelemetryName(), Enum::"Feature Uptake Status"::Used);
        FeatureTelemetry.LogUsage('0000IIY', ICMapping.GetFeatureTelemetryName(), 'IC Inbox Transaction Created');

        if TempRegisteredPartner."Auto. Accept Transactions" then
            if not IsICInboxTransactionReturnedByPartner(ICInboxTransaction."Transaction Source") then
                ICDataExchange.EnqueueAutoAcceptedICInboxTransaction(ICPartner, ICInboxTransaction);
    end;
 
I have the same question (0)
  • Verified answer
    Aman Kakkar Profile Picture
    149 on at
    How to bypass "Auto. Accept Transactions" when posting Intercompany Journals via AL Code
    Thanks everyone for the valuable suggestions and guidance!

    I’d like to summarize the code snippets I used to enable Auto-Send and Auto-Accept Intercompany (IC) transactions without relying on the standard “Auto-Send Transaction” and “Auto-Accept Transaction” setup booleans.

    Pre-Requisites-

    Regardless of whether you are using the IC Default Template and Batch or a custom Template/Batch, you must configure the IC Default Template and Batch in Intercompany Setup in the Partner Company. Otherwise, Auto-Acceptance of IC transactions will fail.

    Auto-Send Transactions-

    In the standard report "IC Outbox Export" there’s a function:

        procedure ProcessAutoSendOutboxTransactionNo(ICOutboxTransactionNo: Integer)
        var
            ICSetup: Record "IC Setup";
            IsHandled: Boolean;
        begin
            IsHandled := false;
            OnBeforeProcessAutoSendOutboxTransactionNo(ICOutboxTransactionNo, IsHandled);
            if IsHandled then
                exit;
    
            ICSetup.Get();
            if ICSetup."Auto. Send Transactions" then
                ModifyAndRunOutboxTransactionNo(ICOutboxTransactionNo);
        end;
     
    This checks the Auto-Send boolean before sending transactions to the partner company.

    Inside there, it eventually calls - "ModifyAndRunOutboxTransactionNo". This function can be copied into a custom codeunit and invoked wherever you need to bypass the Auto-Send boolean dependency:
     
    local procedure ModifyAndRunOutboxTransactionNo(ICOutboxTransactionNo: Integer)
    var
        ICOutboxTransaction: Record "IC Outbox Transaction";
    begin
        ICOutboxTransaction.SetRange("Transaction No.", ICOutboxTransactionNo);
        if ICOutboxTransaction.FindFirst() then begin
            ICOutboxTransaction."Line Action" := ICOutboxTransaction."Line Action"::"Send to IC Partner";
            ICOutboxTransaction.Modify();
            RunOutboxTransactions(ICOutboxTransaction);
        end;
    end;
    
     
     
    For Auto-Accept Transactions- 
     
    The standard report "Move IC Trans. to Partner Comp" (Report 513) raises an event: "OnICInboxTransactionCreated".
     
    This event is subscribed by Codeunit 790 "IC Inbox Outbox Subscribers", where Auto-Accept is checked before enqueuing transactions.
    [EventSubscriber(ObjectType::Report, Report::"Move IC Trans. to Partner Comp", 'OnICInboxTransactionCreated', '', false, false)]
        local procedure AcceptOnAfterInsertICInboxTransaction(var Sender: Report "Move IC Trans. to Partner Comp"; var ICInboxTransaction: Record "IC Inbox Transaction"; PartnerCompanyName: Text)
        var
            ICPartner: Record "IC Partner";
            TempRegisteredPartner: Record "IC Partner" temporary;
            FeatureTelemetry: Codeunit "Feature Telemetry";
            ICMapping: Codeunit "IC Mapping";
            ICDataExchange: Interface "IC Data Exchange";
        begin
            ICPartner.SetRange("Inbox Details", PartnerCompanyName);
            if not ICPartner.FindFirst() then
                exit;
    
            ICDataExchange := ICPartner."Data Exchange Type";
            ICDataExchange.GetICPartnerFromICPartner(ICPartner, TempRegisteredPartner);
    
            FeatureTelemetry.LogUptake('0000IIX', ICMapping.GetFeatureTelemetryName(), Enum::"Feature Uptake Status"::Used);
            FeatureTelemetry.LogUsage('0000IIY', ICMapping.GetFeatureTelemetryName(), 'IC Inbox Transaction Created');
    
            if TempRegisteredPartner."Auto. Accept Transactions" then
                if not IsICInboxTransactionReturnedByPartner(ICInboxTransaction."Transaction Source") then
                    ICDataExchange.EnqueueAutoAcceptedICInboxTransaction(ICPartner, ICInboxTransaction);
        end;
     
    If you try "Go To Definition" for "EnqueueAutoAcceptedICInboxTransaction", then you will end up landing on an Interface where you will not be able to see any Code.
     
    So better go to Codeunit 532 and search for "EnqueueAutoAcceptedICInboxTransaction" and copy paste it in your custom code.
    procedure EnqueueAutoAcceptedICInboxTransaction(ICPartner: Record "IC Partner"; ICInboxTransaction: Record "IC Inbox Transaction")
    var
        JobQueueEntry: Record "Job Queue Entry";
    begin
        if not JobQueueEntry.ChangeCompany(ICPartner."Inbox Details") then
            Error(FailedToChangeCompanyErr, JobQueueEntry.TableCaption, ICPartner.Name);
    
        if not JobQueueEntry.ReadPermission() then
            Error(MissingPermissionToReadTableErr, JobQueueEntry.TableCaption, ICPartner.Name);
    
        JobQueueEntry."Object Type to Run" := JobQueueEntry."Object Type to Run"::Codeunit;
        JobQueueEntry."Object ID to Run" := Codeunit::"IC Inbox Outbox Subs. Runner";
        JobQueueEntry."Maximum No. of Attempts to Run" := 3;
        JobQueueEntry."Recurring Job" := false;
        JobQueueEntry."Record ID to Process" := ICInboxTransaction.RecordId;
        JobQueueEntry."Job Queue Category Code" := JobQueueCategoryCodeTxt;
        JobQueueEntry."Run in User Session" := false;
        JobQueueEntry.Status := JobQueueEntry.Status::Ready;
        JobQueueEntry.Description := StrSubstNo(AutoAcceptTransactionTxt, ICInboxTransaction."Transaction No.", ICInboxTransaction."IC Partner Code", ICInboxTransaction."Document No.");
        JobQueueEntry.Insert(true);
        CODEUNIT.Run(CODEUNIT::"Job Queue - Enqueue", JobQueueEntry);
    end;
    

    Bringing It Together-

    Finally, we can combine both steps into a single reusable procedure and call it whenever posting IC journal lines:

    procedure AutoSendAndAutoAcceptTransaction(var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; var GenJournalLines: Record "Gen. Journal Line"; ICPartnerCode: Code[20])
    var
        ICInboxOutboxMgt: Codeunit ICInboxOutboxMgt;
        ICTransactionNo: Integer;
        ICSetup: Record "IC Setup";
        ICPartner: Record "IC Partner";
        ICInboxTransaction: Record "IC Inbox Transaction";
    begin
        GenJnlPostLine.RunWithCheck(GenJournalLines);
    
        ICTransactionNo := ICInboxOutboxMgt.CreateOutboxJnlTransaction(GenJournalLines, false);
        ICInboxOutboxMgt.CreateOutboxJnlLine(ICTransactionNo, 1, GenJournalLines);
    
        ModifyAndRunOutboxTransactionNo(ICTransactionNo);
    
        ICSetup.Get();
        if ICPartner.Get(ICPartnerCode) then begin
            ICInboxTransaction.ChangeCompany(ICPartner."Inbox Details");
            if ICInboxTransaction.Get(ICTransactionNo, ICSetup."IC Inbox Details", ICInboxTransaction."Transaction Source"::"Created by Partner", ICInboxTransaction."Document Type"::" ") then
                EnqueueAutoAcceptedICInboxTransaction(ICPartner, ICInboxTransaction);
        end;
    end;
    Now, when you post your Custom IC Journal Lines — either together with invoices or through custom actions — they will be automatically sent and accepted without requiring the standard Auto-Send or Auto-Accept settings.

    If you notice that your custom Enqueue function is being triggered but Auto-Accept still doesn’t complete, check the Job Queue Log Entries for any errors that may have occurred during processing.

    Occasionally, you might encounter an error similar to the one shown below.
     
    The IC Inbox Transaction does not exist. Identification fields and values: Transaction No.='257',IC Partner Code='Random',Transaction Source='Created by Partner',Document Type=' '
     
    This can be safely ignored — it happens when the standard Auto-Accept logic runs after your custom code has already accepted the transaction, resulting in a duplicate attempt.
     
  • Verified answer
    Rishabh Kanaskar Profile Picture
    3,563 on at
    How to bypass "Auto. Accept Transactions" when posting Intercompany Journals via AL Code
    Hi,
     
    You cannot reliably change the built-in check (no IsHandled) at the point it runs. Recommended approach: leave standard flow intact and add your own small process that finds new IC Inbox transactions for the specific Journal Template+Batch and calls the partner’s IC Data Exchange enqueue method to accept them regardless of the partner flag. Run it immediately after posting (Job Queue or called from your posting flow). This avoids modifying base logic and works per-template/batch.
     
    AL pattern:
     
    codeunit 50150 "IC AutoAccept Runner"
    {
        SingleInstance = true;
        procedure Run(AFilterTemplate: Code[20]; AFilterBatch: Code[20])
        var
            ICInboxTrans: Record "IC Inbox Transaction";
            ICPartner: Record "IC Partner";
            ICDataExchange: Interface "IC Data Exchange";
        begin
            ICInboxTrans.SetRange(Status, ICInboxTrans.Status::New);
            if AFilterTemplate <> '' then
                ICInboxTrans.SetRange("Source Template", AFilterTemplate);
            if AFilterBatch <> '' then
                ICInboxTrans.SetRange("Source Batch", AFilterBatch);
            if not ICInboxTrans.FindSet() then
                exit;
            repeat
                if ICPartner.Get(ICInboxTrans."Inbox Details") then begin
                    ICDataExchange := ICPartner."Data Exchange Type";
                    // call enqueue directly to force acceptance regardless of partner setting
                    ICDataExchange.EnqueueAutoAcceptedICInboxTransaction(ICPartner, ICInboxTrans);
                end;
            until ICInboxTrans.Next() = 0;
        end;
    }

    How to use:
    > Call this codeunit from a Job Queue entry that runs immediately after your IC Journal posting, or
    > Call it from your posting AL flow when the journal template/batch matches your one-off requirement.
     
    Notes:
    > Ensure the job runs with appropriate permissions.
    > Test for idempotency and duplicate enqueue handling in a sandbox.
    > This approach avoids changing Microsoft code and gives you per-template/batch control.
     
    Thanks
    Rishabh
  • Suggested answer
    YUN ZHU Profile Picture
    92,020 Super User 2025 Season 2 on at
    How to bypass "Auto. Accept Transactions" when posting Intercompany Journals via AL Code
    Hi, this can be submitted to Microsoft.
     
    Hope this helps.
    Thanks.
    ZHU
  • Aman Kakkar Profile Picture
    149 on at
    How to bypass "Auto. Accept Transactions" when posting Intercompany Journals via AL Code
    Hi Suresh, Thanks for your response.
     
    That was my question - how to make the changes in that Temporary record or to completely bypass the Job Queue logic that standard uses. Currently, I do not have any privilege to make any changes in this process. Can you share a code snippet if possible, as it will help me a bit more to understand the approach?
     
    Thanks again.
  • Suresh Kulla Profile Picture
    49,986 Super User 2025 Season 2 on at
    How to bypass "Auto. Accept Transactions" when posting Intercompany Journals via AL Code
    It uses the interface to retrieve the Registered Partner. If you can implement the IC Data Exchange Partner interface to update the GetICPartnerSetup, you can adjust the boolean on the Temporary record. Try that method.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 3,864

#2
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 3,185

#3
Sumit Singh Profile Picture

Sumit Singh 2,850

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans