Skip to main content

Posts

Showing posts with the label Form Customization

Fetching Company Details in X++

In D365FO, retrieving legal entity details like logos, addresses, and tax IDs is a common requirement for reports and custom documents. The  CompanyInfo table is your primary source for this data. Instead of writing complex joins, use these built-in methods to fetch data for the current company context: CompanyInfo companyInfo = CompanyInfo::find(); // Populate your table or variables tmp.CompanyLogo = FormLetter::companyLogo(); tmp.CompanyName = companyInfo.Name; tmp.CompanyAddress = companyInfo.postalAddress().Address; tmp.Telephone = companyInfo.phone(); tmp.Fax = companyInfo.teleFax(); tmp.Giro = companyInfo.Giro; tmp.TaxRegistrationNumber = companyInfo.CoRegNum; Why this works: CompanyInfo::find() : Automatically fetches the record for your current legal entity. FormLetter::companyLogo() : The standard way to grab the company logo for documents. Helper Methods : Methods like .phone() and .postalAddress() save you f...

CoC of Modified Field Method in X++

  In Dynamics 365 Finance and Operations, the modifiedField method on tables is crucial for automating data entry. For example, when a user enters an ItemId , we typically want to automatically populate the Custom ItemName field . While you could directly override this method on a custom table, what happens when you need to add this logic to a standard table, or when you want to extend existing logic on a custom table like SalesLine ? The answer is Chain of Command (CoC) . Using CoC allows us to wrap the standard modifiedField logic, injecting our custom code either before or after the standard execution, all without overlayering or breaking upgrade compatibility. The CoC Implementation Here is how you implement CoC on the  SalesLine  table to populate  Custom ItemName  when ItemId changes. You create a new class that extends the table. [ExtensionOf(tableStr(SalesLine))] final class SalesLine_Extension { public void modifiedField(FieldId _fieldId) ...

Modified Field Method in X++

  In Dynamics 365 Finance and Operations, user experience is everything. If a user enters an ItemId , they shouldn't have to manually type the ItemName . We can automate this using the modifiedField override on the table level. The ModifiedField  method is a kernel method that triggers after a field's value has been changed. It's the perfect place to put logic for fetching related data or resetting dependent fields. The Implementation On your custom table MNZFRSalesLine , you will override the  ModifiedField  method. We use a switch  statement on the _fieldId parameter to ensure our code only runs when the ItemId is the field being touched. public void modifiedField(FieldId _fieldId) { super(_fieldId); switch (_fieldId) { case fieldNum(MNZFRSalesLine, ItemId): if (this.ItemId) { // Fetch the Item Name using the InventTable find method // inventTable.itemName() is a common helper method ...

How to Configure Microsoft Graph API for Email in Dynamics 365 Finance & Operations

Meta Description: Learn how to replace SMTP with Microsoft Graph API in D365FO. A step-by-step guide to Azure App Registration, API permissions (Mail.Send), and Email Parameter setup. Introduction With Microsoft moving towards modern authentication, the traditional SMTP setup in Dynamics 365 Finance & Operations is being phased out. Using Microsoft Graph API is now the standard for sending secure, reliable emails. In this post, I will walk you through the technical configuration required to bridge Azure Active Directory (Entra ID) and D365FO. Phase 1: Azure Portal Configuration The first step is creating a secure entry point in the Azure Portal. (You must have admin rights on Azure Portal ) App Registration: Create a new registration named DemoMails . (Write your own name) Credentials: Note down the Application (Client) ID API Permissions: This is the most crucial part. You must add Application Permissions for Mail.Send under Microsoft Graph. Crucial Step: Don't forget...

How to Add Financial Dimensions to Sales Orders in Dynamics 365 F&O X++

When creating sales orders through X++ in Dynamics 365 F&O, you may need to assign financial dimensions programmatically . This is useful for integrations, automation, or custom processes where dimensions should be applied automatically. In this example, we create a SalesTable record and attach multiple financial dimensions. 1. Build the Financial Dimension Set First, create a helper method that collects dimension values and returns a DefaultDimension . private DimensionDefault addFinancialDimension(                                                                                                  OMOperatingUnitNumber _businessUnit,              ...

Create Transfer Order Line by Scanning Barcode in Dynamics 365 Finance & Operations X++

Create Lines By Scanning Barcode on Transfer Order / Sales Order / Purchase Order Forms When working with  Transfer Order / Sales Order / Purchase Order  in Dynamics 365 F&O, the standard behavior requires the user to manually select the Item ID every time they add a new line. But in many warehouses, users simply want to scan the barcode and automatically have the related item appear on the line — saving time and reducing manual errors. Recently, I implemented this exact requirement : When a user scans the item barcode on the Transfer Order line, the system should automatically fetch the Item ID linked with that barcode and populate the line. To achieve this, I created a custom barcode field on the InventTransferLine table named MZNFRItemBarCode , and then added logic to validate the barcode and populate the ItemId automatically. Below is the code I used. X++ Code — Auto Populate Item ID By Scanning Barcode [ExtensionOf(tableStr(InventTransferLine))] final clas...