Posts

🚀 Export All D365 F&O Custom Models with a Single Batch File

  In Microsoft Dynamics 365 Finance and Operations (D365 F&O), managing and exporting models can be a repetitive task, especially when you're dealing with a large number of custom models. To streamline this process, you can automate model exports using a simple batch file. In this blog, I’ll walk you through how to create a .bat file that exports all your custom models in one go—without needing to execute each command manually. This is especially helpful during regular backups or before code deployments. 🧠 Why Use a Batch File? A batch file allows you to: Export multiple models in one go Create backups with date-based folders automatically Reduce human error and save time Reuse and modify easily 📂 Folder Structure Assumption In this example, we're assuming the following: D365 metadata is located at K:\AosService\PackagesLocalDirectory ModelUtil.exe is located in K:\AosService\PackagesLocalDirectory\bin You want to store exported models in  ...

Customer aging report for multiple legal entities

Image
In one of our client, there were more than 5 legal entities which share the same customers as the customer were merged from Global address book. System doesn't provide the aging for multiple legal entities, so it was very difficult for the user to export the aging report from each company and then merge them because there were thousands of customers. Hence it was decided to create a separate aging report. First I created a query in AOT. Here is the contract class to get As on date. [DataContractAttribute] class DSS_CustomerAgingComparisonContract {     Amount      Amount;     FromDate    asOnDate;     [DataMemberAttribute("As On Date") ,SysOperationLabelAttribute(literalStr('As of date'))]     public FromDate parmFromDate(FromDate _asOnDate = asOnDate)     {         asOnDate = _asOnDate;         return asOnDate;     } } ...

Dynamics - Change custom financial dimension ID in system

While we were fetching data for reporting purpose in power BI, we were facing an issue because one of the custom dimension contained & symbol in its name. So in order to get the report in power BI we had to change the dimension name and replace '&' with 'And'. For applying this change directly in database [Because we cannot change it from front end] we went through each table which have or may have records relavent to financial dimensions. In doing so, I found below table in which I had to change the name of the dimension. DimensionAttributeValueCombination DimensionAttributeLevelValue DimensionAttributeValueSetItem GeneralJournalAccountEntry DirPartyTable We executed following query to achieve this. Update DIMENSIONATTRIBUTELEVELVALUE Set    DISPLAYVALUE = replace(DISPLAYVALUE, '&', 'And') WHERE DISPLAYVALUE LIKE '%&%' Update DIMENSIONATTRIBUTEVALUESETITEM Set    DISPLAYVALUE = replace(DISPLAYVALU...

Dynamics 365 - Create, Update or delete records directly from database

Image
As we all know that we don't have the access to the database and there are times where we need to create update or delete a record directly from database. So, In order to get this thing done. I created a form from which I can directly execute the query. It can be enhanced but just to give you the idea how to do it.  Here is the form design. Set QueryControl's allow declaration property to YES. Override ExecuteBtn's click event and write the following code. List            queryList = new List(Types::String); ListIterator    iterator; str             sqlQuery; DialogButton    diagBut; str             strMessage = "Are you sure you want to execute this query?"; str             strTitle = "Execute" ; super(); diagBut = Box::yesNo(strMessage, DialogButton::No,  strTitle); if (diagBut == DialogButton::...

SQL stored procedure to get Item's on hand on specified date

One of my client needed to have an inventory data text file generated directly from SQL query, In which there was a need have on hand inventory of items on specified date but not on inventory dimensions. So I went through system's class InventOnhand which is responsible for getting item's on hand on provided date and replicate the same logic to get item's on hand without considering inventory dimensions but a few tweaking will be required to get on hand on different dimensions. Here is the SP which require item number and date to get its on hand. USE [MicrosoftDynamicsAX] GO /****** Object:  StoredProcedure [dbo].[FG_ItemOnHand]    Script Date: 2/5/2018 10:56:49 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[FG_ItemOnHand] @ItemId nvarchar(20), @AsOfDate DATE, @OnHand DECIMAL(16, 2) OUTPUT AS DECLARE @Posted DECIMAL(16, 2), @Received DECIMAL(16, 2), @Deducted DECIMAL(16, 2), @Picked DECIMAL(16, 2), @Regi...

Fastest way to clean InventSumLogTTS

Fastest way to clean InventSumLogTTS table. Just drop the table from SQL management studio. DROP TABLE InventSumLogTTS and then from AX re-synchronize InventSumLogTTS table.

Convert real number to time string

While I was developing a report for payroll module, We had done some customization for storing employee's total working hours in a separate table and I had to develop a report for employee's time sheet to show his/her time in and time out. As I was getting total time in hour [Real number] so I had to change real hour to time and then calculate employee's time in and time out for each day of the month. Here is the code to convert real hour to time. static void realHour2Time(Args _args) {     int     hours, minutes;     real    fractionalPart, hourInReal = 7.3555;     str     minStr, timeStr;     if (hourInReal != 0)     {         hours = trunc(hourInReal );         fractionalPart = hourInReal - hours;         minutes = fractionalPart*60;         if (strLen(strFmt("%1", minutes)) == 1)     ...