Category Archives: Tips & Tricks

Combine & Merging images to a single image using X++ & C# Dot Net Libraries

How to Merge Two Brands: Successful M&A

Requirement – The requirement is to combine and merging images to a single image using X++ & C# Dot Net Libraries in Microsoft Dynamics 365 finance and operation.

Classes & Libraries –

System.Drawing.Bitmap
System.Drawing.Image
System.Drawing.Graphics
System.Drawing.Imaging.ImageFormat
System.Drawing.Color

Sample Code –

str jpg1 = @”c:\images.jpeg”;
str jpg2 = @”c:\images2.jpeg”;
str jpg3 = @”c:\image3.jpg”;

System.Drawing.Image img1 = System.Drawing.Image::FromFile(jpg1);
System.Drawing.Image img2 = System.Drawing.Image::FromFile(jpg2);

int width = img1.Width + img2.Width;
int height = System.Math::Max(img1.Height, img2.Height);

System.Drawing.Bitmap img3 = new System.Drawing.Bitmap(width, height);

System.Drawing.Graphics g = System.Drawing.Graphics::FromImage(img3);

g.Clear(System.Drawing.Color::Black);
g.DrawImage(img1, new Point(0, 0));
g.DrawImage(img2, new Point(img1.Width, 0));

g.Dispose();
img1.Dispose();
img2.Dispose();

img3.Save(jpg3, System.Drawing.Imaging.ImageFormat::Jpeg);
img3.Dispose();

What is AdminUserProvisioning Tool in Microsoft D365 fin & ops ? Add Admin user after backup restore

In various ERP implementation & support projects, sometime it is very hard to replicate a production / UAT environment scenario in dev box for debugging or in some cases it is tedious to do any kind of unit testing due to lack of business data. But luckily, we can solve this problem by doing restoration of transaction database backup in your dev box from a UAT or production .In most of cases, developer can only access in his/her development box and developer is not allowed to access in UAT/Production sever . After restoring database backup, developer starts to face issue – “You are not authorized to login with your current credentials. You will be redirected to login page in few seconds” because his/her developer login ID is not available in AXDB D365 FO database .

To solve this issue, Microsoft has provided a tool called – AdminUserProvisioning.exe . After restoring the database from your UAT/PROD server in your development box, you can add your userId in your dev box D365 FO instance.

The path of tool AdminUserProvisioning.exe is C:\AOSService\PackagesLocalDirectory\bin\AdminUserProvisioning.exe

OR

K:\AOSService\PackagesLocalDirectory\bin\AdminUserProvisioning.exe

Archive inventory transactions (Purge InventTrans) in Microsoft Dynamics 365 for finance and operations

As we know, “InventTrans” table is one of the largest table in Microsoft D365 for finance and operations and this table keep growing through out the ERP lifecycle and consume more space. BUT ! here is the good news that Microsoft has released a standard feature and a standard batch job to archive inventory transactions and purge InventTrans table data.

Here is the Microsoft document link – https://docs.microsoft.com/en-us/dynamics365/supply-chain/inventory/archive-inventory-transactions

cheers,

Piyush Adhikari

D365 FO – Create deep links, shareable, secured URLs in Microsoft Dynamics 365 for finance & operations

A complete guide to mobile app deep linking | Adjust

What is deep links in Microsoft Dynamics 365 for finance and operation? Deep links are shareable and secures URLs to a specific form. Optional filters can be passed so that when user will open the deep link and navigate to a specific form then it will show filtered data ore records. In Microsoft D365 FO, below library – Microsoft.Dynamics.AX.Framework.Utilities.UrlHelper.UrlGenerator is used to generate deep links using X++ .

Sample Code – Below is the sample code of developing & generating deep links for D365 FO forms and records using filter and ranges in form data source. In below example, i am generating the sharable URL (deep link ) of a form – CustAccount and applying a “CustAccount” filter on custTable datasource.

using Microsoft.Dynamics.AX.Framework.Utilities; // setting library/Dll reference

class DeepLinkTest
{
    public static void main(Args _args)
    {
        MenuItemNameDisplay menuItemName                = menuItemDisplayStr(CustTable);  // customer form
        MenuItemType        menuItemtype                = MenuItemType::Display;
        str                 filterformDataSource        = formDataSourceStr(CustTable, CustTable);  // filer datasource
        str                 filterFormDataSourceField   = fieldStr(CustTable, AccountNum); // filter field

        UrlHelper.UrlGenerator generator = new UrlHelper.UrlGenerator();
        System.Uri currentHost = new System.Uri(UrlUtility::getUrl());
 
        generator.HostUrl = currentHost.GetLeftPart(System.UriPartial::Authority);
        generator.Company = curExt();
        generator.MenuItemName = menuItemName;
        generator.MenuItemType = menuItemtype;
        generator.Partition = getCurrentPartition();
        generator.EncryptRequestQuery = true; 
        if(filterformDataSource)
        {
            UrlHelper.RequestQueryParameterCollection requestQueryParameterCollection;
 
            requestQueryParameterCollection = generator.RequestQueryParameterCollection;
            requestQueryParameterCollection.UpdateOrAddEntry(filterformDataSource, filterFormDataSourceField, "CustAccount"); // applying filter
        } 

        System.Uri fullURI = generator.GenerateFullUrl();
 
        Info(fullURI.AbsoluteUri); // getting deep link
    }

}

Upload & Read JSON File from Local Folder

Breaking Changes in ArduinoJson 6.0 - Wia Community

Requirement:

Customer has saved some JSON files in local folder of laptop or server or drive. Customer wants upload the JSON files from local drive to microsoft Dynamics 365 finance and operations for further business process. A dialog will open in Microsoft D365 fin & ops, customer will select JSON files and import.

Continue reading Upload & Read JSON File from Local Folder

D365 FO:Catch exceptions & Inner exceptions thrown from CLR objects Using ClrInterop & X++

Exception Handling in Java | Java Exceptions - javatpoint

In Microsoft Dynamics 365 for finance and operations, when you use .Net assemblies or classes it is important that you code should handle & capture & catch all the .Net inner exceptions.

Missing module(s):The selected package is missing the following modules that are currently deployed on your environment

Error- During the package deployment or applying VSTS/DevOps build package in UAT or Production , below error is coming in LCS (Life cycle services

The selected package is missing the following modules that are currently deployed on your environment.
You must create an all in-one deployable package that contains all your code customisations & ISV solutions.More information can be found at the following link:https://go.microsoft.com/fwlink/?linkid=2118104.Missing module(s) [AcxDocumentReports]

D365 FO: Data Entity “onMappingEntityToDataSource” event

Requirement

In Microsoft Dynamics 365 finance and operations, client has an data entity for importing list of customer account into a table.During the time of importing of customer accounts using Data entity, client also want to capture & save values of few fields.

Continue reading D365 FO: Data Entity “onMappingEntityToDataSource” event