Microsoft Dynamics 365 Business Central is a powerful Enterprise Resource Planning (ERP) solution that offers a wide range of customization options to meet the unique needs of your business. One such customization is the ability to dynamically create a custom email subject in Dynamics 365 Business Central using AL code for different document types, when sending emails from Business Central. This customization can be useful when you want to make your email subjects more descriptive and informative, making it easier for recipients to understand the context of the email.
We recently encountered a requirement to customize the email subject when sending quotes and invoices to customers. Instead of using the Out-of-the-Box (OOTB) subject lines provided by Business Central
In Dynamics 365 Business Central, email subjects are generated by “Codeunit 260 – Document-Mailing” using the “GetEmailSubject” function. To customize the email subject, we will utilize an event, “OnBeforeGetEmailSubject”.
Step 1: Create a New AL Codeunit
codeunit 70100 INK_Email_Subject { [EventSubscriber(ObjectType::Codeunit, Codeunit::"Document-Mailing", 'OnBeforeGetEmailSubject', '', false, false)] local procedure MyProcedure(var EmailSubject: Text[250]; PostedDocNo: Code[20]; ReportUsage: Integer; var IsHandled: Boolean) var ReportUsageEnum: Enum "Report Selection Usage"; begin // Convert ReportUsage from Integer to Enum ReportUsageEnum := "Report Selection Usage".FromInteger(ReportUsage); // Check if ReportUsage is "S.Quote" if ReportUsageEnum = ReportUsageEnum::"S.Quote" then begin // Customize the email subject for "S.Quote" EmailSubject := CompanyProperty.DisplayName() + ' - Quote Number - ' + PostedDocNo; IsHandled := true; end else if ReportUsageEnum = ReportUsageEnum::"S.Invoice" then begin // Customize the email subject for "S.Invoice" EmailSubject := CompanyProperty.DisplayName() + ' - Invoice Number - ' + PostedDocNo; IsHandled := true; end; end; var myInt: Integer; }
Step 2: Publish and Install the Extension
After creating the codeunit, you’ll need to publish and install the extension in your Dynamics 365 Business Central instance.
Step 3: Test the Customization
Customizing email subjects in Microsoft Dynamics 365 Business Central using AL code can greatly improve your communication efficiency and help recipients better understand the context of your emails. Before deploying custom code in a production environment, thorough testing in a sandbox environment is essential to ensure that it functions as expected and does not disrupt your business processes. With this customization, you can enhance the communication by providing more informative and personalized email subjects for different document types.
ATM Inspection PowerApp to ease ATM inspection and report generation process.
https://www.inkeysolutions.com/microsoft-power-platform/power-app/atm-inspection
Insert data into Many-to-Many relationship in Dynamics CRM very easily & quickly, using the Drag and drop listbox.
http://www.inkeysolutions.com/what-we-do/dynamicscrmaddons/drag-and-drop-listbox
Comply your Lead, Contact, and User entities of D365 CRM with GDPR compliance using the GDPR add-on.
https://www.inkeysolutions.com/microsoft-dynamics-365/dynamicscrmaddons/gdpr
Create a personal / system view in Dynamics CRM with all the fields on the form/s which you select for a particular entity using the View Creator.
http://www.inkeysolutions.com/what-we-do/dynamicscrmaddons/view-creator
© All Rights Reserved. Inkey IT Solutions Pvt. Ltd. 2024
Leave a Reply