Posts

TableId by given table name.

Image
In Dynamics 365 Finance & Operations, we get table id by using tableNum() method and on sql we get by using the system table  SYSTABLEIDVIEW   SYSTABLEIDVIEW is used to look up the mapping between a table name and its Table ID. select * from SYSTABLEIDVIEW where Name = 'hcmworker' 👉 What it does: Looks up the table hcmworker. Returns metadata, including: TableID → the unique integer ID assigned to hcmworker . Name → table name. Possibly additional system columns depending on SQL setup. ✅ Example output: Table id by using x++: int tableId = tableNum(hcmWorker); str tableName = tableId2Name(tableId);

How to use logged in company data into code

As a Dynamics 365 Finance & Operations (D365FO) Technical Consultant , one of the common requirements is to fetch details of the current legal entity (company) . Here’s a small but powerful X++ line that helps us: CompanyInfo companyInfo = CompanyInfo::findRecId(CompanyInfo::current()); 👉 CompanyInfo A standard table in D365FO. Stores company-specific details like Name, Address, Currency, Tax info, Contact details etc. 👉 CompanyInfo::current() Returns the RecId of the company you are currently logged into. Example: If you are in USMF, it gives the RecId of USMF. 👉 CompanyInfo::findRecId(...) Finds and returns the full CompanyInfo record for the given RecId. ✅ Together, they give you all the details of the logged-in company. Example: CompanyInfo companyInfo = CompanyInfo::findRecId(CompanyInfo::current()); info(strFmt("You are logged into company: %1", companyInfo.Name)); info(strFmt("Default currency: %1", companyInfo.CurrencyCode)); 🌟 Why is this useful? N...

Generate error on empty Financial Dimensions in D365FO

When working with Human Resources and Finance integration in Dynamics 365 Finance and Operations (D365FO), ensuring financial dimensions are properly defined on employee records is critical for accurate reporting and budgeting. In this blog, we'll look at how to enforce required dimensions using a validatedWrite event handler on the HcmEmployment table. We'll use an event handler on the HcmEmployment table's validatedWrite method to check for the presence of specific dimensions on the DefaultDimension field. [DataEventHandler(tableStr(HcmEmployment), DataEventType::ValidatedWrite)]     public static void HcmEmployment_onValidatedWrite(Common sender, DataEventArgs e)     {         HcmEmployment HcmEmployment = sender as HcmEmployment;           DimensionAttributeValueSetStorage dimAttrValueSetStorage;         DimensionAttribute dimensionAttribute;         // List of required fina...

JSON-Based HTTP POST Request from X++ to Retrieve an Access Token

In today's connected systems, integrations between Dynamics AX and external APIs are essential. One common scenario is retrieving an access token from a remote API for authentication. In this post, I'll show you how to make a POST request with JSON from X++ and handle the response. We'll walk through a complete example where we send credentials to an API and parse the response to retrieve an access token. Prerequisites To follow along, you should have: Basic familiarity with X++ Access to System.Net and System.IO namespaces via CLR Interop A configured HRMParameters table to store credentials X++ code: System.Net.HttpWebRequest                 request; System.Net.HttpWebResponse              response; System.IO.StreamWriter                       streamWriter; System.IO.StreamReader              ...

Sending Form Data from form in D365FO Using a Button Click

In this blog post, I’ll walk you through how to implement a button click handler in Dynamics 365 Finance and Operations (D365FO) to send data to an external API.   Requirement I had a requirement where I needed to send the selected worker's data to an external API when a button is clicked on the HcmWorkerV2 form. To achieve this, I used a form control event handler that is triggered when the custom button is clicked. Implementation Here’s the X++ code that handles the button click: [FormControlEventHandler(formControlStr(HcmWorkerV2, SendApiData), FormControlEventType::Clicked)] public static void SendApiData_OnClicked(FormControl sender, FormControlEventArgs e) {     FormCommandButtonControl callerButton = sender as FormCommandButtonControl;     FormRun form = callerButton.formRun();     // Get the form datasource and current worker record     FormDataSource hcmWorker_ds = form.dataSource(formDataSourceStr(HcmWorkerV2, HcmWorker)) as...

Passing Multiple Selected Records from a Form to an SSRS Report in D365FO

Recently, I had a requirement in Dynamics 365 Finance & Operations (D365FO) to pass multiple selected records from a form to an SSRS report. To achieve this, I used the MultiSelectionHelper class, which allows you to retrieve all selected records from a form's grid.   Step-by-Step Implementation To implement this functionality, I created: A contract class to hold the list of selected RecId s. A controller class to fetch the selected records using MultiSelectionHelper. A data provider (DP) class to process and insert the selected records into a temporary table for the report. Contract Class The contract class contains a list of RecId s: List recid; [     DataMemberAttribute('recId'),     SysOperationHelpTextAttribute(literalStr("Rec Id")),     SysOperationLabelAttribute(literalStr("Rec Id")),     SysOperationDisplayOrderAttribute('0'),     AifCollectionType('return', Types::Int64) ] public List parmRecId(List _re...

How to Show or Hide a Tablix Row in SSRS Report in D365FO

Image
Recently, I had a requirement in Dynamics 365 Finance & Operations (D365FO) where I needed to conditionally show or hide a specific row inside a tablix in an SSRS report. In this blog, I’ll explain how I achieve this by using a value , and use it to control row visibility inside a tablix. Scenario Let’s say your tablix contains multiple rows: | Employee | Department | Salary | Extra Info Row (Bonus, Notes, etc.) | You want to show/hide the "Extra Info" row based on a value selected by the user. Step-by-Step Implementation      Design your tablix with multiple rows. For example: Row 1: Employee Info Row 2: Salary Details Row 3: Extra Info (this is the row we’ll hide/show)      Set Visibility for the Specific Row Click on the row handle (left side grey bar) for the row you want to show/hide. Right-click → Row Visibility… Choose: "Show or hide based on an expression"                ...