Tag Archives: d365 f&o

D365 FO:JSON Creation & SERIALIZATION Using FormJsonSerializer & X++

Requirement

SON CREATION & SERIALIZATION USING FORMJSONSERIALIZER & X++ in Microsoft Dynamics 365 for finance and operations.

Format Of Output JSON String & Message

{"itemCategory":123456,"itemClassification":"A","itemCode":"ItemXYZ","itemGroup":"ItemGroup","itemname":"ItemXYZ Name","onDate":"/Date(1597363200000)/","Optimized":"Yes","site":"SiteCode"}
Continue reading D365 FO:JSON Creation & SERIALIZATION Using FormJsonSerializer & X++

D365 FO – Generate next Number sequence in X++ using NumberSeq Class

Requirement – D365 FO – GENERATE NEXT NUMBER SEQUENCE IN X++ USING NUMBERSEQ CLASS

Continue reading D365 FO – Generate next Number sequence in X++ using NumberSeq Class

‘RunAs’ function & method in Dynamics 365 Finance & Operations

Introduction:

There are some scenarios in Microsoft Dynamics 365 finance and operations where we need to run X++ program or code or business operation on the behalf of different userId other than current userId.

In my case, my X++ program of D365 finance and operations should always run under the userId- ADMIN . I can use ‘RunAs’ function & method in Dynamics 365 Finance & Operations.

Sample Code:

class AcxSharepointIntegeration
{
    public static container download(container _parms)
    {
        RunAsPermission perm;
        perm = new RunAsPermission("Admin");
        perm.assert();
        Container returncontainer = runAs("Admin", classnum(AcxSharepointIntegeration), "get", _parms);
        CodeAccessPermission::revertAssert();
        return returncontainer;
    }

    public static container get(container _parms)
    {
        container con;
        // Your business Logic
        return   con; 
    }

class AcxSharepointIntegeration
{
public static container download(container _parms)
{
RunAsPermission perm;
perm = new RunAsPermission(“Admin”);
perm.assert();
Container returncontainer = runAs(“Admin”, classnum(AcxSharepointIntegeration), “get”, _parms);
CodeAccessPermission::revertAssert();
return returncontainer;
}

public static container get(container _parms)
{
container con;
// Your business Logic
return con;
}

D365 FO : SQL Connection & Access of production environment Using X++

  • Introduction – In earlier version of Microsoft Dynamics AX, Customer and partner had full control and access of Microsoft SQL Server and they were able to connect to Microsoft SQL Server of production server.Customer and partner were also able to use SSMS (SQL Server Management Server) in Microsoft Dynamics AX Production for querying and executing direct SQL Statements in certain scenarios.
  • But In Microsoft Dynamics 365 finance and operation Cloud & SaaS (Software as a service application) model , you cannot connect to Microsoft SQL server of production and you don’t have any access of production server SQL.
  • Only Microsoft has full control of production servers and responsible for tasks like maintenance, backups etc.
  • Customer is using LCS (Life cycle services) for deployments, service upgrades etc.
  • It is not recommend to execute direct SQL statement in SQL server of production but still in certain scenarios we need it.
  • Steps to connect SQL server of Microsoft Dynamics finance and operations production environment and executing SQL statements directly using X++
  • In this example, login to visual studio and create a runnable class in Microsoft D365 finance & operations.

  • Write the below code, for SQL update and delete command execution in production server SQL database.
  • Above piece of code works just fine when you are executing SQL update or delete statements or commands. But in some scenarios, we have to use SQL select commands or statements directly in production SQL.
  • In below screenshot and code i am showing how can we execute direct SQL statement and command.
  • The difference bewtween update/delete & select sql statement is that in select i am using method statement.executeQuery(sqlStr) whereas in update/delete SQL statement i am using statement.executeUpdate(sqlStr).
  • In this way we can execute SQL update, delete, select etc statements and commands in the production SQL database of Microsoft dynamics 365 finance and operations using X++.
  • Also read my post on D365/AX7:Connect To An External SQL Database Using X++.

D365 FO/AX7/Class Extension: COC (Chain of command) & Method Wrapping With Example

  • Introduction COC (chain of command) & Method Wrapping In Microsoft Dynamics 365 finance and operations –
  • Microsoft D365 Finance and operations supports very powerful feature called COC or method wrapping.
  • In past, Microsoft Dynamics AX/Axapta supports overlayering where you can overlayer Microsoft classes, table methods etc directly by placing your code in the middle, bottom or top if standard code. Below is screenshot and example for your reference. In below screenshot i placed my custom code in the middle of standard method by using overlayering.
  • In Microsoft Dynamics 365 finance and operations (After version 8.0) , you cannot overlayer code as everything is sealed now. We have to use COC or method wrapping.Microsoft has improved the Functionality of Class extension for D365 FO by adding wrap logic around methods which are defined in the base class that you are augmenting. You can Wrap or do Chain of command (COC) of public and protected methods.
  • In below screenshot i am using method wrapping or class extension of standard class which is different from Microsoft Dynamics AX overlayering approach.

  • Next keyword means to call the orginal method “ChecItemPostingDate” of standard class “InventUpdate”
  • You can get values of Global Variables of in your extension class of your parent class or main class.
  • Final Modifier means The method can’t be overridden in any class that derives from its class.
  • Here are one more example where we are using COC (chain of commands) in Table methods.

Benefits Of Using Change Of Commands instead of Old Overlayering approach in Microsoft Dynamics 365 finance and operations

  1. Easy Future upgrades and version enhancements as you are not doing overlayering in standard classes or methods or objects & keeping you separate extension classes.
  2. Neat & Clean development as no need to compile whole code librarary.

D365 FO/AX7: Composite Data Entities Vs Data Entities With Example

  • Introduction – Data management framework of Microsoft Dynamics 365 finance and operations contains a very important technical asset called Data Entities. Data entities are conceptual combinations, abstraction and encapsulation of one of more underlying tables. Data entities in Microsoft D365 finance and operations are used to import and export data in Microsoft Dynamics finance and operations. Odata integration can also be achieved using D365 finance and operations data entities. We can customize standard data entity . Click Here to know about standard data entity customization.
  • Composite Data entity vs Simple Data Entity- There are some differences between Composite Data entity & Simple Data Entity. 1 ) First of all simple data entity contains one or more tables where as composite data entity contains multiple data entities 2) Simple Data entities support Odata & can be used in Odata integration whereas Composite data entities cannot be used Odata integration.
  • Where should we use Composite Data entity ?-Composite entity is used in scenarios where an entity can be represented as a single document, like Purchase Header/line , Sales header/line, Invoice header/line etc.
  • Example & Development of Composite Data entity steps are mentioned below :
  • In example i am taking 2 separate standard data entities i.e. PurchPurchaseOrderHeaderV2Entity & PurchPurchaseOrderLineV2Entity
  • PurchPurchaseOrderHeaderV2Entity contains purchase order header information & fields mainly purchTable Fields
  • PurchPurchaseOrderLineV2Entity contains purchase order Lines information & fields mainly PurchLine Fields
  • We will develop a new composite data entity by using above 2 data entities and compose data entity will represent a single purchase order document (Purchase Order Header + Purchase Order Line)
  • Now create a composite data entity in your project.
  • Extend PurchPurchaseOrderLineV2Entity and create relation with PurchPurchaseOrderHeaderV2Entity. (NOTE In my case standard relation is already there so no need to create any customize relation)
  • Right click on your composite data entity and add “New Root Data Entity Reference” and make sure property Data Entity should be equal to PurchPurchaseOrderHeaderV2Entity
  • Right click on your “New Root Data Entity Reference” PurchPurchaseOrderHeaderV2Entity and add “New Embedded Data Entity Reference” equals to PurchPurchaseOrderLineV2Entity & Property Relation should be equal to PurchaseOrderHeader.
  • Extend staging table (PurchPurchaseOrderLineV2Staging) of data entity PurchPurchaseOrderLineV2Entity and add relation with the staging table (PurchPurchaseOrderHeaderV2Staging) of data entity PurchPurchaseOrderHeaderV2Entity.(NOTE : In my case standard relation already exist so i am not creating any relation)
  • Add two columns, RowId and ParentRowId (type int), on all the staging tables i.e. PurchPurchaseOrderHeaderV2Staging & PurchPurchaseOrderLineV2Staging.
  • Create a cluster index on the staging tables which includes RowId, ParentRowid,DefinitionGroup, and ExecutionId for getting good performance .
  • Build and synchronize your project
  • Under “Data import/export framework parameters”, select fast tab “Entity Settings” and click on “Refresh Entity List”. Here is LINK AND TUTORIAL.

D365 FO/AX7: Merge Branches Or Moving Changes from One Branch To Another in VSTS/Azure DevOps

Requirement: In last post i demonstrated how can we create A New Production Branch In VSTS (Visual Studio Team Services)/Azure DevOps & Microsoft Dynamics 365 finance and operations. To See my last post please click here. In this post i will show how can we Merge Branches in VSTS/Azure DevOps and Microsoft Dynamics D365 finance and operations or how can we move change or CHANGESets from one dev branch to another prod branch. Before starting this tutorial i will recommend you to please go through my last post.To See my last post please click here

  • Right Click on SOURCE Branch & choose option MERGE
  • Browse TARGET Branch
  • You can choose 2 option for branch changes you would like to merge.First one is “ALL CHANGES UPTO SPECIFIC VERSION” & second one is “SELCTED CHANGESETS
  • Click NEXT and FINISH

D365 FO/AX7: Create A New Prod Branch In VSTS/Azure DevOps

Introduction : In Microsoft Dynamics 365 & VSTS/Azue DevOps practice, it is always recommended to use a separate branch for production deployment else incomplete code of developer will get included in production deployment package.Developers checkedIn code or any development changes frequently in one dev branch but package should not be created from that branch in which developer is doing checkIn. Only required changes should be merged from dev branch to prod branch in Microsoft Dynamics 365 finance and operation & VSTS/Azue DevOps. Please click here to read my post – D365 FO/AX7: Merge Branches Or Moving Changes from One Branch To Another in VSTS/Azure DevOps

Requirement : Create A New Production Branch In VSTS (Visual Studio Team Services)/Azure DevOps & Microsoft Dynamics 365 finance and operations.

Once Branch of production will be created you can merge code from DEV branch to PROD branch as per requirement.In next tutorial i will show you how can we merge code from one branch to another.

  • Login to your Microsoft Dynamics 365 finance and operations development server.
  • Open visual studio in Microsoft Dynamics 365 finance and operations development server using run as administrator.
  • Click on VIEW tab and open TEAM EXPLORER in Visual studio of D365 fo development server.
  • Open SOURCE CONTROL EXPLORER
  • Create a NEW BRANCH.

D365 FO/AX7: Mobile App & Mobile Workspaces With Example

Introduction – The Microsoft Dynamics 365 mobile app allows you to access your business processes, data and records from mobile phones and tablets. Microsoft Dynamics D365 Mobile workspaces can be enabled in a very less time with almost no effort. Using Microsoft Dynamics D365 fins and operations mobile user can easily perform below activities :

1. User can view Microsoft Dynamics D365 finance and operations business data in mobile app.

2. User can edit or delete Microsoft Dynamics D365 finance and operations business data in mobile app.

3. Admin can add certain tasks and CRUD operations in D365 workspace and mobile app. User can perform those operations in D365 mobile app.

Example – Below are the steps to create your first Microsoft Dynamics D365 mobile app.

  1. In this scenario we are using vendor master and we will public vendor master workspace and user will be able to view vendor master in D365 mobile app.
  1. Go to settings menu and click on mobile app in Microsoft Dynamics 365.
  1. Create new Microsoft Dynamics 365 mobile app.
  1. Fill all the details of Microsoft Dynamics 365 mobile app.
  1. Add page in Microsoft Dynamics 365 mobile app.
  1. Select fields
  1. Save the Microsoft Dynamics 365 mobile app.
  2. Publish the Microsoft Dynamics 365 workspace and mobile app.
  3. Login into your Microsoft Dynamics 365 mobile app and start using it

D365/AX7: Uninstall/Remove a Model/Package From Production & UAT Environment

Requirement

Uninstall/Remove a Model/Package From Production & UAT Environment of Microsoft Dynamics Finance and operations.

Steps

  1. Create a file that is named ModuleToRemove.txt.
  2. In the file, put the name of each module that you want to remove on a separate line. Make sure that you’ve completed the prerequisites for each module that you’re removing.
  3. Create a valid deployable package, and put the ModuleToRemove.txt file in the package\AOSService\Scripts folder.
  4. Install/Deploy the deployable package in UAT or production environment.
  5. Verify that the package was uninstalled before you complete this procedure in a production environment.