How to Extend Sales Confirmation on Batched and Single Runs in D365 Finance and Supply Chain Management
Ever needed to trigger a custom action during the Sales Order Confirmation process in Dynamics 365 Finance & Supply Chain Management? Whether it’s running manually or in a batch job?
For example, your business may want to update a third-party system, log additional audit details, or apply custom validations before confirming orders. Out of the box, D365 doesn’t give you a direct hook for this, but with a simple extension, you can inject your logic seamlessly into both manual and multithreaded confirmations.
If you are ever racking your brain on how to hook into or extend the sales confirmation process to take a custom action when it's running batched and/or manual, we have a solution for you!
// Batch Hook
[ExtensionOf(classStr(FormletterParmDataCreateDataBatchTask))]
final class FormletterParmDataCreateDataBatchTask_StoneridgeSoftware_Extension
{
public void run()
{
next run();
// This is a batched/multithreaded SO Confirm.
// For manual SO Confirm, see SalesFormLetter_Confirm_StoneridgeSoftware_Extension
switch (this.parmFormletterType())
{
case FormletterType::Sales :
FormLetterContract formLetterContract = this.parmFormletterContract();
switch(formLetterContract.getDocumentStatus())
{
case DocumentStatus::Confirmation:
ParmId parmIdLoc = this.parmFormletterContract().parmParmId();
SalesTable salesTable;
SalesParmSubTable salesParmSubTable;
while select salesTable
exists join salesParmSubTable
where salesParmSubTable.ParmId == parmIdLoc
&& salesTable.SalesId == salesParmSubTable.OrigSalesId
{
// TODO ACTION
}
break;
}
break;
}
}
}
// Manual hook
[ExtensionOf(classStr(SalesFormLetter_Confirm))]
final class SalesFormLetter_Confirm_StoneridgeSoftware_Extension
{
public void run()
{
SalesTable salesTable = this.salesTable();
// This is a manual SO Confirm.
// For batched/multithreaded SO Confirm, see FormletterParmDataCreateDataBatchTask_StoneridgeSoftware_Extension
if(salesTable)
{
// TODO ACTION
}
next run();
}
}
It's as simple as that!
Troubleshoot D365 Finance and Supply Chain Smarter and Quicker with Stoneridge!
Need more assistance with your D365 Finance & Supply Chain environment? We've got some of the best developers and support resources in the biz. If you need help with implementation or support, we can assist with both proactive and break/fix issues. Talk to our team today!
Under the terms of this license, you are authorized to share and redistribute the content across various mediums, subject to adherence to the specified conditions: you must provide proper attribution to Stoneridge as the original creator in a manner that does not imply their endorsement of your use, the material is to be utilized solely for non-commercial purposes, and alterations, modifications, or derivative works based on the original material are strictly prohibited.
Responsibility rests with the licensee to ensure that their use of the material does not violate any other rights.

