In this blog we will learn about how we can by-pass the Intercompany Setup's "Auto. Send Transactions" in base company and "Auto. Accept Transactions" in the Partner Company while posting IC Journals in the base company. Sometimes, we want to post some IC Journal lines via AL Code, where we don't want to touch the standard process. We can use the below procedures/events that will help us in this particular scenario.
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 in the partner company.
For Auto. Send Transactions-
In the standard report "IC Outbox Export" there’s a function:
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:
For Auto. Accept Transactions-
The standard report "Move IC Trans. to Partner Comp" (Report 513) is used for accepting the inbox transactions, which also raises an event: "OnICInboxTransactionCreated".
This event is subscribed by Codeunit 790 "IC Inbox Outbox Subscribers", where Auto-Accept is checked before enqueuing transactions.
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. This is basically used for accepting the inbox transactions in the partner company.
Bringing It Together-
Finally, we can combine both steps into a single reusable procedure and call it whenever posting IC journal lines. I have added a custom procedure that can be used for calling the procedures that we created till now:
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.