• 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

Dynamic 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.

How to fetch un-Invoiced Delivery notes for sales order – D365 Finance and Operations

March 1, 2025 by alirazazaidi

So here is another code snippet, that I develop after two hours of testing and understanding the D365 F&O that get all non invoiced , delivery notes or packingslip. I want to restrict the code to invoice against Delivery note, If no non posted delivery note exists, Code will not generate the invoice.

 public static str getUninvoicedPackingSlipsBySalesId(SalesId _salesId)
 {
     CustPackingSlipJour custPackingSlipJour;    // Packing slip journal
     InventTrans         inventTrans;            // Inventory transaction

     str packingSlipIds = "";
     container distinctPackingSlips;             // Container to store unique Packing Slip IDs
     int i = 0;

     // Fetch only un-invoiced Packing Slips based on Sales ID
     while select inventTrans
     where inventTrans.InvoiceId == ""
     
     join custPackingSlipJour
     where custPackingSlipJour.PackingSlipId == inventTrans.PackingSlipId
       && custPackingSlipJour.SalesId == _salesId
     {
         // Check if the Packing Slip ID is already in the container
         if (conFind(distinctPackingSlips, custPackingSlipJour.PackingSlipId) == 0)
         {
             distinctPackingSlips += custPackingSlipJour.PackingSlipId;  // Add to container if unique
                          
         }
     }

     return con2Str(distinctPackingSlips);  // Return the comma-separated string or empty if none found
 }

How to use Voucher Template Dynamics 365 finance and Operations

April 18, 2022 by alirazazaidi

Version used 10.0.24

Data Manipulation in Dynamics Ax 2012- Array as Extended Data Type

July 2, 2018 by alirazazaidi

I found a array based field in TSTimesheetLineWeek table, Field TSWeeklyHours

Now challenge is to enabled field based on Array. For example need to disabled on day 6.

Following code snippet help me to enabled disabled fields generated on the base of array extended Type

TSTimesheetLineWeek_ds.object(fieldId2Ext(fieldNum(TSTimesheetLineWeek, Hours), 6)).allowEdit(false);

Reference :

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

https://docs.microsoft.com/en-us/previous-versions/dynamicsax-2009/developer/aa592700(v=ax.50)

Special character In Query range, Dynamics ax 2012 R3 and DFO 365 for operation.

April 26, 2017 by alirazazaidi

Yesterday I got very interesting issue. So When put filter on color, config, style and size. A strange error occur. Filter works for 99% of records but on 1 percent time out occurs. When we dig deep into issue, we found that End user, used the special character ‘(‘ in style. And when we execute the filter on dim of special character reports goes toward timeout. It means some infinite loop occurs.

Our code snippet was

 findOrCreateRange_W(query.dataSourceTable(tableNum(InventDim)), fieldNum(InventDim, InventStyleId)).value(InventDimParm.InventStyleId);

Later we found that queryValue is missing in our statement. That was the reason statement was goes into infinite loop.

The correct statement is below as.

  findOrCreateRange_W(query.dataSourceTable(tableNum(InventDim)), fieldNum(InventDim, InventStyleId)).value(queryValue(InventDimParm.InventStyleId));

Data manipulation tip 1 In Dynamics ax 2012 and D365 Of Operations Data copy method.

April 9, 2017 by alirazazaidi

 

Currently I am doing Report development project, I got some tips for Data manipulation , these tips I recently learned.

 

Copy data from one table buffer to other of same type.

 

 

During report development, We usually populate  temp table with result of Query execution. Usually we need copy of same data for aggregate functions.

 

Instead map each field of buffer with each other. We can copy the whole data by using .data method.

 

 

Suppose we have custom temp table CustSaleQtyTmp which we need to copy from one buffer to other.

class DataManipulationJob
{
/// <summary>
/// Runs the class with the specified arguments.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
public static void main(Args _args)
{

CustSaleQtytmp _temp1,_temp2;
_temp1.IntQty=100;
_temp1.CustAccount =”Cust00001″;
_temp1.insert();
_temp1.IntQty=200;
_temp1.CustAccount =”Cust00002″;
_temp1.insert();

_temp1.IntQty=300;
_temp1.CustAccount =”Cust00003″;
_temp1.insert();
while select * from _temp1
{
// Instead copy like this we can use Data method
// _temp1.CustAccount = _temp2.CustAccount;
// _temp1.IntQty = _temp2.IntQty;

_temp2.data(_temp1);
_temp2.insert();

}

while select * from _temp2
{
info( ” _temp2 with ” + _temp2.CustAccount + ” ” + int2Str(_temp2.IntQty));

}
}

}

output like

Financial dimension for work position Dynamics Ax 2012.

August 15, 2016 by alirazazaidi

 

I used following code snippet to get financial dimension attached with hcmposition

 

static void GetFinancialDimensionValue1(Args _args)

{

HcmPosition  position;

HcmPositionDefaultDimension  positionDefaultDimention;

DimensionAttributeValueSetStorage dimStorage;

Counter i;

select * from position

join * from positionDefaultDimention

 

where position.PositionId=="000001"

&& position.RecId == positionDefaultDimention.Position;

 

 

 

dimStorage = DimensionAttributeValueSetStorage::find(positionDefaultDimention.DefaultDimension);

 

for (i=1 ; i<= dimStorage.elements() ; i++)

{

 

info(strFmt("%1 = %2", DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name,

dimStorage.getDisplayValueByIndex(i)));

 

}

}

2016-08-15_23-14-22

 

Reference:  https://jkmsdax2012.wordpress.com/2015/11/16/how-to-get-financial-dimensions-for-a-particular-customer-using-x-code-in-ax-2012/

Cannot edit a record .. An Update Conflict occurred due to … Dynamics Ax 2012 R3.

August 11, 2016 by alirazazaidi

today I got this error while running a custom report.

Cannot edit a record in  Table

An update conflict occurred due to another user process deleting the record or changing one or more fields in the record.

 

 

I found that this error occurs due to concurrent access to table is allowed. And we did not need concurrent access.

I change the ccEnabled to no

Concurrent

 

 

If this error occur on table that can be used on concurrent mode, then write tableBuffer.reread() before adding or modify data.

 

 

Reference: https://community.dynamics.com/ax/f/33/t/95177

water mark in SSRS report Dynamics Ax 2012.

August 4, 2016 by alirazazaidi

Hi, all very small tip today, Recently I have to add water mark in one of custom report.

In SSRS for Dynamics Ax 2012, we can achieve water mark by adding background image in report body.

Water mark image should be small in size and used as background Image. If you use high in size image, Report will threw errors on deployed at server.

This water mark can hide and show with ssrs expression.

So complete real word requirement will be Print report with water mark if certain criteria meets, other wise print report normal report.

 

At SSRS side right right  click on report Body and click on Body Properties.

2016-08-04_11-38-16

From property window, select fill, select file the image source “embedded” and import file.

Import

After import file will be shown as report explorer

 

Duplicate

Now add following expression  to show report display water mark or not.

 

=IIf(Fields! DuplicateCopy.Value=1,”Duplicate3″,””)

How to run RDP based report from X++ and passing parameter using Data contract.

July 19, 2016 by alirazazaidi

Interesting, I was modifying some RDP based report, I found that parameter was passed to report through custom table, As report will run form button, and based on current selected record. So former developer did that on pressing button, selected value inserted some custom table. When report run, query on table and fetch required value form custom table and whole report logic run on that value. That approach works fine, single user environment. Problem I found to send parameter to report through x++ code. I found SrsReportRunController works wonder here.

Suppose we are running some report for customer, And Report Name is customer Report and we have to pass current customer account on form as parameter. If you report is based on Report data provider than following code snippet works for you.

 

 

 

SrsReportRunController          controller = new SrsReportRunController();

CustomerReprtDC  rdpContract = new CustomerReprtDC  ();

SRSPrintDestinationSettings     settings;

super();

controller.parmReportName(ssrsReportStr(CustomerReport,CustomerCopy));

 

 

controller.parmShowDialog(false);

rdpContract.parmCustAccount(CustTable.AccountNum);

controller.parmReportContract().parmRdpContract(rdpContract);

controller.startOperation();

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