Thursday 22 January 2015

How to retrieve selected and checked record from grid in Dynamics AX

There are two methods to retrieve the selected or marked records from a grid and a data source we use a loop to perform this operation there is a little bit difference in the code to retrieve the selected marked record and selected unmarked record.
1. When we want to retrieve the selected unmarked record we use the following code
StudentsChecked studentLocal;
super();
studentLocal = StudentsChecked_ds.getFirst (true);
for(studentLocal = StudentsChecked_ds.getFirst(true) ? StudentsChecked_ds.getFirst (true) :
StudentsChecked_ds.cursor (); studentLocal; studentLocal = StudentsChecked_ds.getNext ())
{
Info (studentLocal.Name +”–” +studentLocal.Id);
}
This loop returns the record that is pointed by cursor.
2. And when we want to retrieve the selected marked records we use the following code
StudentsChecked studentLocal;
super();
studentLocal = StudentsChecked_ds.getFirst (true);
for(studentLocal = StudentsChecked_ds.getFirst(true); studentLocal;
studentLocal = StudentsChecked_ds.getNext ())
{
Info (studentLocal.Name +”–” +studentLocal.Id);
}
This loop returns the records that are marked or checked.

Upgrade SSRS reports from Dynamics AX 2012 R2 to AX 2012 R3

Upgrade from Dynamics AX 2012 R2 to Dynamics AX 2012 R3 is really painful and we face many challenges and errors. I got following error when I tried to deploy some modified report which upgrade to R3:


Error      Message (4:25:24 pm) An error occurred while deploying the report PurchPurchaseOrder. 
This might be because the SQL Server Reporting Services extensions have not been installed on the report server, or configuration information has not been entered in the Report Servers form in Microsoft Dynamics AX.

Error      Message (4:25:24 pm) System.Web.Services.Protocols.SoapException: Error while loading code module: ‘Microsoft.Dynamics.Framework.Metadata.AX, Version=6.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’. Details: Could not load file or assembly 'Microsoft.Dynamics.Framework.Metadata.AX, Version=6.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
   at Microsoft.ReportingServices.WebServer.ReportingService2005Impl.CreateReport(String Report, String Parent, Boolean Overwrite, Byte[] Definition, Property[] Properties, Warning[]& Warnings)
   at Microsoft.ReportingServices.WebServer.ReportingService2005.CreateReport(String Report, String Parent, Boolean Overwrite, Byte[] Definition, Property[] Properties, Warning[]& Warnings)

Info        Message (4:25:24 pm) Report name: PurchPurchaseOrder
Design names: PurchPurchaseOrder.Report
Deployment status for design names: Error
Assembly names: PurchPurchaseOrder.BusinessLogic.dll, DrillThroughCommon.dll
Deployment status for assembly names: Success, Success

One solution if this error is to open respective VS report project in VS environment and build it and deploy it. But in some cases its not working. 
So the other workaround is to hack the code, you should export the report which throw above error, and open the XPO in notepad and search the tag 6.2.0.0 and replace it with 6.3.0.0 and import.
Here is the sample:
#
#    Microsoft.Dynamics.Framework.Reports, Version=6.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
#    Microsoft.Dynamics.Framework.Metadata.AX, Version=6.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

to replace with:

#
#    Microsoft.Dynamics.Framework.Reports, Version=6.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
#    Microsoft.Dynamics.Framework.Metadata.AX, Version=6.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35