• Skip to main content
  • Skip to primary sidebar
  • Home
  • About
  • Recommended Readings
    • 2022 Book Reading
    • 2023 Recommended Readings
    • Book Reading 2024
    • Book Reading 2025
  • Supply Chain Management Guide
  • PKM
  • Microsoft Excel

Ali Raza Zaidi

A practitioner’s musings on Dynamics 365 Finance and Operations

Dynamics Ax 2012

Json deserialize issue in service class An exception occured when invoking the operation – Type ‘Class’ is not supported by serializer. D365 Finance and operations

April 10, 2025 by alirazazaidi

Yesterday, I was working on integration, and everything was going fine. However, when I tried to retrieve a string from the DataContract, it threw an error: “Type ‘Class’ is not supported by the serializer.” The issue persisted even when I used Newtonsoft. The rest of the logic was functioning correctly.

Eventually, I discovered that the issue was due to missing AX 2012 attributes on the list’s getter/setter or parameter. Once I added those attributes, the actual getter/setter started working as expected.

 [
    DataMemberAttribute('transactions'),  
    DataCollectionAttribute(Types::Class, classStr(DSTTransactionDC))  
  ]  
  public List Parmtransactions(List _transactions = transactions)  
  {  
    transactions = _transactions;  
return transactions;
  }

I have to add following

  AifCollectionTypeAttribute('_transactions', Types::Class, classStr(DSTTransactionDC)),
  AifCollectionTypeAttribute('return', Types::Class, classStr(DSTTransactionDC))

After that getter setter become something similar

 [
    DataMemberAttribute('transactions'),  
    DataCollectionAttribute(Types::Class, classStr(DSTTransactionDC)),  
    AifCollectionTypeAttribute('_transactions', Types::Class, classStr(DSTTransactionDC)),  
    AifCollectionTypeAttribute('return', Types::Class, classStr(DSTTransactionDC))  
  ]  
  public List Parmtransactions(List _transactions = transactions)  
  {  
    transactions = _transactions;  
 return transactions;
  }

after this change, datacontract easily serialise. 
Also change attribute at class header from datacontracattribute to dataContract.

Hope you like this post.

Json empty string to Null D365 finance and operations

June 10, 2024 by alirazazaidi

Small tip today

str myJson = FormJsonSerializer::serializeClass(sContract);
        myJson = strReplace(myJson,":"",",": null,");
        return myJson;

Like this

How to use Voucher Template Dynamics 365 finance and Operations

April 18, 2022 by alirazazaidi

Version used 10.0.24

MB-330: Microsoft Dynamics 365 Supply Chain Management | Product and Product Master

October 28, 2021 by alirazazaidi

First video in the series of preparation guide for MB-330 Certification guide.

Dynamics Ax 2012 R3 Contoso Demo VM license 2019

February 22, 2019 by alirazazaidi

Today I need to explore some control sample in Dynamics ax 2012 R3. For opening Ax 2012 r3 on my machine, I need a demo license.

I found demo license for 2019 on following location.

Relation between VendPackingSlipJour and PurchParmTable Dynamics Ax 2012 R3

December 7, 2017 by alirazazaidi

Couple of days ago, I was helping a young developer. Who was doing some customization. He added some customization in PurchParmtable and want information in VendPackingSlipJour Table.

It was very strange that there is no direct relationship between vendPackingSlipJour and  PurchParmTable.

 

After Exploring I found that There is ParmId field in VendPackingSlipVersion table.

And we can get VendPackingSlipVersion by static method with PurchId and PackingSlipId, DeliveryDate.

 

This ParmId has relation with PurchParmTable.

I wrote down following code snippet to get Value from PurchParmTable, with respect to VendPackingSlipVersion.

 

 

 

display real _netWeight()
{
PurchParmTable _purchParmTbl;
parmid _id;
_id=VendPackingSlipVersion::findFromInterCompanyPackingSlip((this.PurchId),
(this.PackingSlipId),(this.DeliveryDate)).ParmId;
select *from _purchParmTbl where _purchParmTbl.ParmId==_id;
return _purchParmTbl.NetWeght;
}

 

Hopes this help

ODBC connection and Null value Handling Dynamics Ax 2012 R3.

December 5, 2017 by alirazazaidi

Today I have very small tip to share. I noted down, some odbc connection posts in my blog. All these post shares the code snippets , that used to open odbc connection and did query on SQL server directly. Couple of days ago, I need similar code snippet to read data from SQL server and Insert into another connect. But that code did not had reference to handling null values. So I note down that code snippet too, for future reference.

 

These all odbc connection , command return results in “ResultSet” class.

 

This ResultSet  class has method  “wasnull”. According to documentation, its behavior is strange. First we have to call the get method and then we call “WasNull” to verify that value appears is null or not.

https://msdn.microsoft.com/en-us/library/resultset.wasnull.aspx

 

So whole code snippet will be like.

public void run()
 

{

Connection Con = new Connection();

ResultSet R;

str sql;

Statement Stmt;

SqlStatementExecutePermission permission;

Real _RealValue;

sql = "SELECT * FROM InventTrans ";

Stmt = Con.createStatement();

permission = new SqlStatementExecutePermission(sql);

permission.assert();

R =Stmt.executeQuery(sql);

 

while ( R.next() )

{

_RealValue =R.getReal(1);

if (  R.wasNull(1) ==boolean::false)

{

 

info (" Not null");

}

Else

{

Info (" Null ");

}

 

 

 

}

CodeAccessPermission::revertAssert();

 

}

Select on InventSum vs InventOnHand Class Dynamics Ax 2012 R3.

August 22, 2017 by alirazazaidi

Today I face the very strange behavior of X++ code.

We develop customization. We generate transfer and issuance through X++.

Logic was very simple,If stock is available then transfer  / Issuance or Adjustment journal create otherwise generate error message, We took this decision  based of query on Inventsum. It works fine in most of cases but In one case when stock is zero it fails. We create Movement Journal to generate stock in that Item variant.  The select query always return Zero stock in posted quantity. Even I get the recid in debug mode and placed in table explorer, Quantity is available in table explore.

This case occurs when got Zero stock in Inventsum table and we try to increase stock by movement journal, other wise select on InventSum works fine.

 

The query will be very similar

 

Select * from InventSum where Inventsum.ItemId == line.ItemId && inventSum.invetdimId == line.fromInventiDimId;

 

This will not work. Even Db synch, Inc Cil, Cache clear done, even Restart the Test server AOS.

 

I have to switch code from select query to Class InventOnhand. Very similar to following.

 

InventOnHand inventOnhand

InventDim       InventDim;

InventDimParm inventDimParm;

 

 

inventDimParm.initFormInventDim(_Line.FromInventDimId);

inventOnHand = InventOnhand::newParameters(_line.Itemid,_line.FromInventDimId,inventDimParm);

 

If (inventOnHand.availPhysical() > _line.RequestedQty)

{

Info( ” Quantity Avalible “);

}

Else

{

Info (” Not available “);

}

 

Its works perfectly fine. I think  InventonHand class is better the do direct query on Inventsum table.

 

Skip certain values Report group sum SSRS Dynamics Ax 2012 R3. Dynamics 365 for operations

July 3, 2017 by alirazazaidi

There is again small tips. Let me share you again scenario. Suppose you have to show customer Sale With customer group level. And group footer want to sum of Sales of that group. Now requirement is that customer with certain sub classification will skip in group sum. For example those customer who are on hold or blocked will not shown in report group sum, but shown in report detail

I was developing RDP based reports. So I add a int field in table. So I can mark specific record need to skip at group level sum.

I update the following SSRS expression to skip certain records at group level.

=Sum(iif(Fields!Flag.Value= 0, Cdbl(Fields!Value.Value), 0.0),”Group Name”)

Data manipulation tip 2 Dynamics ax 2012 and D365 of Operations Table initialization method.

April 12, 2017 by alirazazaidi

If we consider the following code snippet.
CustSalesQty _temp1,_temp2;
_temp1.IntQty=100;

_temp1.CustAccount =”Cust00001″;

_temp1.insert();

_temp1.IntQty=200;

_temp1.insert();

 

_temp1.IntQty=300;

_temp1.CustAccount =”Cust00003″;

_temp1.insert();

while select * from _temp1

{

_temp2.data(_temp1);

_temp2.insert();

 

 

 

}

 

while select * from  _temp2

{

info( ” _temp2 with ” + _temp2.CustAccount + ” ” + int2Str(_temp2.IntQty));

 

}

 

 

}

You can check that when we insert the temp1.inQTY=200, We did not set Customer account. At result record new record will insert with customer Cust00001 . You can see output of above code

 

 

Point is simple, We need to initialize the table before populate for next values.  I found this scenario in custom Inventory reports. When we populate data in different fields based on issue status.

You can set initialized values after ate in side query execution loop. But that piece of code belongs to specific location.

Microsoft provide the out of the box base initValue method. You can add this method by following way.

Best practices says you have to initialize value in this method. And call this method with table reference. This way initialization is table dependent not class dependent.

 

So we can over write the code as follow

public class CustSalesQty extends common

{

/// <summary>

///

/// </summary>

public void initValue()

{

super();

this.IntQty =0;

this.CustAccount =””;

}

 

}

Now above code snippet will works as

class Job123

{

/// <summary>

/// Runs the class with the specified arguments.

/// </summary>

/// <param name = “_args”>The specified arguments.</param>

public static void main(Args _args)

{

CustSalesQty _temp1,_temp2;

_temp1.initValue();

_temp1.IntQty=100;

_temp1.CustAccount =”Cust00001″;

_temp1.insert();

_temp1.initValue();

_temp1.IntQty=200;

//  _temp1.CustAccount =”Cust00002″;

_temp1.insert();

_temp1.initValue();

_temp1.IntQty=300;

_temp1.CustAccount =”Cust00003″;

_temp1.insert();

while select * from _temp1

{

_temp2.initValue();

_temp2.data(_temp1);

_temp2.insert();

 

 

 

}

 

while select * from  _temp2

{

info( ” _temp2 with ” + _temp2.CustAccount + ” ” + int2Str(_temp2.IntQty));

 

}

 

 

}

 

}

Next Page »

Primary Sidebar

About

I am Dynamics AX/365 Finance and Operations consultant with years of implementation experience. I has helped several businesses implement and succeed with Dynamics AX/365 Finance and Operations. The goal of this website is to share insights, tips, and tricks to help end users and IT professionals.

Legal

Content published on this website are opinions, insights, tips, and tricks we have gained from years of Dynamics consulting and may not represent the opinions or views of any current or past employer. Any changes to an ERP system should be thoroughly tested before implementation.

Categories

  • Accounts Payable (2)
  • Advance Warehouse (2)
  • Asset Management (3)
  • Azure Functions (1)
  • Books (6)
  • Certification Guide (3)
  • Customization Tips for D365 for Finance and Operations (62)
  • D365OF (59)
  • Data Management (1)
  • database restore (1)
  • Dynamics 365 (58)
  • Dynamics 365 for finance and operations (135)
  • Dynamics 365 for Operations (165)
  • Dynamics AX (AX 7) (134)
  • Dynamics AX 2012 (274)
  • Dynamics Ax 2012 Forms (13)
  • Dynamics Ax 2012 functional side (16)
  • Dynamics Ax 2012 Reporting SSRS Reports. (31)
  • Dynamics Ax 2012 Technical Side (52)
  • Dynamics Ax 7 (65)
  • Exam MB-330: Microsoft Dynamics 365 Supply Chain Management (7)
  • Excel Addin (1)
  • Favorites (12)
  • Financial Modules (6)
  • Functional (8)
  • Implementations (1)
  • Lifecycle Services (1)
  • Logseq (4)
  • Management Reporter (1)
  • Microsoft Excel (4)
  • MS Dynamics Ax 7 (64)
  • MVP summit (1)
  • MVP summit 2016 (1)
  • New Dynamics Ax (19)
  • Non Defined (9)
  • Note taking Apps (2)
  • Obsidian (3)
  • Personal Knowledge Management (2)
  • PKM (13)
  • Power Platform (6)
  • Procurement (5)
  • procurement and sourcing (5)
  • Product Information Management (4)
  • Product Management (6)
  • Production Control D365 for Finance and Operations (10)
  • Sale Order Process (10)
  • Sale Order Processing (9)
  • Sales and Distribution (5)
  • Soft Skill (1)
  • Supply Chain Management D365 F&O (3)
  • Tips and tricks (278)
  • Uncategorized (165)
  • Upgrade (1)
  • Web Cast (7)
  • White papers (4)
  • X++ (7)

Copyright © 2025 · Magazine Pro On Genesis Framework · WordPress · Log in