Dynamics AX Client freezes and goes to Non Responding State

by alirazazaidi on September 22, 2014

On my local R&D environment, Usually Dynamics Ax client goes on freeze state, especially on first run of Ax client after restart of VM. Finally I found there is issue with ax cache file. I delete the all files with extension “.auc” files from C:\users\userName\appdata\local. After I run the Client, it load in much less time.

{ 0 comments }

Recently we used Master Data Management Framework in Dynamics Ax 2012 for Initial load.. I found that Microsoft release the course on its partner resource.
This course contains following topics

• Module 00: Course Introduction and Expert Introduction
• Module 01: Overview of Data Management
• Module 02: Introduction to Data Import Export Framework
• Module 03: Migrating Data using the Data Import Export Framework
• Module 04: Creating a Custom Entity
• Module 05: Introduction to Master Data Management
• Module 06: Using Master Data Management
• Module 07: Course Review

You can download this eLearning course from following link if you have rights on Partner resource

1. Open this link: https://mbs.microsoft.com/partnersource/northamerica
2. Select Readiness & Training > E-Learning
3. Search for 80645

Reference : http://www.agermark.com/2014/07/new-online-course-data-management-in.html

{ 0 comments }

I got following Error when I called the Read method of Dynamics Ax AIF service.

“Wrong field ID in the key data container in entity key”

 

 

My code snippet is as follow and I did not found anything wrong with it.

StudentInfoRef.KeyField keyField = new StudentInfoRef.KeyField() { Field = "FirstName", Value = "Ali2" };

// Create an entity key instance and put in the key field data

StudentInfoRef.EntityKey entityKey = new   StudentInfoRef.EntityKey();

entityKey.KeyData   = new   StudentInfoRef.KeyField[1] { keyField };

// Create an array of entity keys and put in the previously

 

StudentInfoRef.EntityKey[] entityKeys = new StudentInfoRef.EntityKey[1] { entityKey };

StudentInfoRef.StudentInfoServiceClient _Client = new StudentInfoRef.StudentInfoServiceClient();

StudentInfoRef.CallContext _callContext = new StudentInfoRef.CallContext();

_callContext.Company = "USSI";

StudentInfoRef.AxdStudentInfo _StudentInfo = _Client.read(_callContext, entityKeys);

StudentInfoRef.AxdEntity_StudentInfoTable _StudentInfoTable = _StudentInfo.StudentInfoTable[0];

 

 

After trouble shooting I found that I was trying to read on field which have same value in multiple rows. For example I am trying to read from filed FirstName and value “Ali” exists more than one row.

 

It is recommend that read method will applied on column or field which have unique index.

I was working on testing data, so I delete the all records which have “Ali” value in “FirstName” field. Only one record left for value “Ali”. This time Read method works perfectly right.

It is recommended that if you have repeated values in different rows, you Find method of dynamics Ax 2012.

{ 0 comments }

For one of Presentation on AIF, I build a custom Document Service based on custom table. To avoid any validation constraints I made a very simple custom table “StudentInfoTable”.

FieldName dataType
Roll Number string
FistName string
LastName string
Address string
DateOfBirth date.

 

Create a Unique Index on FirstName field, so Read and find method of custom Document service works fine.

 

 

In AOT under Query Node with Name AxdStudentInfo, create a new DataSource and add StudentInfoTable. Right click on field and set Dynamic Property to Yes

 

Query

 

Now right click on “StudentInfoTable” Node and set its Update properties to true, so Update methods will created against this query object

 

UpdateQuery

 

Now in Development environment from top menu click on AIF frame and then select on Create Document Service and click on it. For this result in running a Wizard

Menu

 

 

Select following options from Wizard, select the query which we create above mentioned drop down. Name the Document Name

 

9-14-2014 10-04-05 AM

Press Next button, from the next button check all the checkbox as per following screen shot.

9-14-2014 10-05-12 AM

Press on Next Button

9-14-2014 10-08-52 AM

Press on Generate button.

9-14-2014 10-12-39 AM

Press On Finished button.

There is possibility of errors in generated code, You can find complete code generated with wizard in private project in Dynamics Ax.

Private Project for Document Services

Right click on AxdStudentInfo and compile again.

You have delete two methods  cacheObject and cacheRecordRecord in AxStudentInfoTable and compile the whole project.

 

Now right click on StudentInfoService and set namespace

http://schemas.Student.com/ServiceContracts

Service reference

Now create a right on Service group Node and create a new service group.

 

Service Group

Drag and drop service node under Student InfoService group. So  Student Service will be available for in side service group.

 

Now generate Inc CIL or right click on StudentInfoServicegroup and click deploy

 

Deploy Service Group

 

 

 

 

 

 

After successful deployment you may find following info box

 

Service InfoBox

 

 

 

 

Now open a new work space and go at System Administration module and open in bound port under Application integration framework

In Bound Port


 

 

And Open Application Inbound framework

 

Address

Copy WSDL URL In my case it is

 

http://WIN-IKPOSIU2SGD:8101/DynamicsAx/Services/StudentInfoServiceGroup

 

now open Visual studio Project and create a new Console project I am more comfortable with C#.

Console

 

 

 

From Solution explore right click and add Service reference

ServiceReference2

 

 

Now we can use following code to create, Read, Update and delete methods

 

Create method

 

 

  StudentInfoRef.AxdEntity_StudentInfoTable _StudentInfo = new StudentInfoRef.AxdEntity_StudentInfoTable();

StudentInfoRef.AxdStudentInfo _Student = new StudentInfoRef.AxdStudentInfo();

_Student.StudentInfoTable = new StudentInfoRef.AxdEntity_StudentInfoTable[1] { _StudentInfo };

 

_StudentInfo.FirstName = "Ali";

_StudentInfo.LastName = " Raza";

_StudentInfo.Address = " Lahore";

_StudentInfo.DateOfBirth = new DateTime(1979, 4, 6);

StudentInfoRef.StudentInfoServiceClient _Client = new StudentInfoRef.StudentInfoServiceClient();

StudentInfoRef.CallContext _callContext = new StudentInfoRef.CallContext();

_callContext.Company = "USSI";

StudentInfoRef.EntityKey[] entityKeys = _Client.create(_callContext, _Student);

You can see create function works fine.
TableExploreCreate
In above mentioned code, Create method take two parameter, first is Call context, In Call context variable we can define legal entity where data will be inserted.

 

 

Read Method

 

Read method use EntityKey for searching criteria for example we want to search Student with First Name Ali following code will works for Us.

Read method works on keyField value. It is recommend that you will search records on the bases of Unique indexed based field.

 

 

 

StudentInfoRef.KeyField keyField = new StudentInfoRef.KeyField() { Field = "FirstName", Value = "Ali2" };

 

// Create an entity key instance and put in the key field data

StudentInfoRef.EntityKey entityKey = new   StudentInfoRef.EntityKey();

 

entityKey.KeyData   = new   StudentInfoRef.KeyField[1] { keyField };

// Create an array of entity keys and put in the previously

 

StudentInfoRef.EntityKey[] entityKeys = new StudentInfoRef.EntityKey[1] { entityKey };

 

 

StudentInfoRef.StudentInfoServiceClient _Client = new StudentInfoRef.StudentInfoServiceClient();

StudentInfoRef.CallContext _callContext = new StudentInfoRef.CallContext();

_callContext.Company = "USSI";

 

StudentInfoRef.AxdStudentInfo _StudentInfo = _Client.read(_callContext, entityKeys);

 

 

StudentInfoRef.AxdEntity_StudentInfoTable _StudentInfoTable = _StudentInfo.StudentInfoTable[0];

 

Console.WriteLine("First Name :" + _StudentInfoTable.FirstName);

Console.WriteLine("Last Name :" + _StudentInfoTable.LastName);

Console.WriteLine("Address :" + _StudentInfoTable.Address);

 

Console.ReadLine();

 

 

 

 

 

 

Update Method

Update in Document is two step process, first step to read the record based on field and second step to update the record which is return as result.

 

 

For example I want to update Address and Last Name of student. Following code works for me.

 

 

 

StudentInfoRef.KeyField keyField = new StudentInfoRef.KeyField() { Field = "FirstName", Value = "Ali2" };

 

// Create an entity key instance and put in the key field data

StudentInfoRef.EntityKey entityKey = new StudentInfoRef.EntityKey();

 

entityKey.KeyData = new StudentInfoRef.KeyField[1] { keyField };

// Create an array of entity keys and put in the previously

 

StudentInfoRef.EntityKey[] entityKeys = new StudentInfoRef.EntityKey[1] { entityKey };

 

 

StudentInfoRef.StudentInfoServiceClient _Client = new StudentInfoRef.StudentInfoServiceClient();

StudentInfoRef.CallContext _callContext = new StudentInfoRef.CallContext();

_callContext.Company = "USSI";

 

StudentInfoRef.AxdStudentInfo _StudentInfo = _Client.read(_callContext, entityKeys);

 

 

StudentInfoRef.AxdEntity_StudentInfoTable _StudentInfoTable = _StudentInfo.StudentInfoTable.First();

 

_StudentInfoTable.Address = "Lahore";

_StudentInfoTable.LastName = "Zaidi";

_StudentInfoTable.action = StudentInfoRef.AxdEnum_AxdEntityAction.update;

_StudentInfoTable.actionSpecified = true;

_Client.update(_callContext, entityKeys, _StudentInfo);

 

 

 

 

Delete Method

 

Delete Method works for same way, Send entity keys and call for Delete method.

 

StudentInfoRef.KeyField keyField = new StudentInfoRef.KeyField() { Field = "FirstName", Value = "Ali2" };

 

// Create an entity key instance and put in the key field data

StudentInfoRef.EntityKey entityKey = new StudentInfoRef.EntityKey();

 

entityKey.KeyData = new StudentInfoRef.KeyField[1] { keyField };

// Create an array of entity keys and put in the previously

 

StudentInfoRef.EntityKey[] entityKeys = new StudentInfoRef.EntityKey[1] { entityKey };

 

 

StudentInfoRef.StudentInfoServiceClient _Client = new StudentInfoRef.StudentInfoServiceClient();

StudentInfoRef.CallContext _callContext = new StudentInfoRef.CallContext();

_callContext.Company = "USSI";

_Client.delete(_callContext, entityKeys);


 

 

 

{ 0 comments }

ENUM values missing in SRSANALYSISENUMS Table

by alirazazaidi on September 12, 2014

During one of assignment, I have to get some data directly from Dynamics Ax table in SQL Server.

All enum based column in table shown their numeric values in Sql Server. For Analysis services Or OLAP services Dynamics Ax holds a table with name “SRSANALYSISENUMS”. This table contains the all enum which are used inside the Cube ETL process.

Analysis services was not install on my machine, for this reason “SRSAnalysisENums” table was empty.

This table is populate with static method “populateSRSAnalysisEnums” of class “BIGenerator”. We can directly run this method to populate the require table so we can join it in SQL server to get enum display/Name in query result instead of their numeric values.

If you have custom table which has one or more tables are based on Enum data type. Or your required enum values are not present in “SRSANALYSISENUMS”.  You have to perform following steps.

  • Create a new prospective.
  • Drag required table in Table node of new prospect.

9-12-2014 6-06-17 PM

  • Save the prospect.
  • Open a new job inside the Dynamics Ax AOT node.

 

  • Run a static method populateSRSAnalysisEnums() of class BIGenerator as follow

static void Job4(Args _args)
{
//BIGenerator _Bi= new BIGenerator();
BIGenerator::populateSRSAnalysisEnums();
}

  • You will find that SRSAnalysisENums” will be populated and your required Enum will be present there.

SRSANALYSISENUMS

{ 0 comments }

Dynamics AX2012 R3 – Virtual Machine download links

by alirazazaidi on September 9, 2014

Hello everybody!

Form the following links you can download the Microsoft Dynamics Ax2012 R3 with Demo data.

 

CostumerSource

https://mbs.microsoft.com/customersource/northamerica/AX/downloads/service-packs/AX2012DemoToolsMaterials

 

PartnerSource

https://mbs.microsoft.com/partnersource/northamerica/sales-marketing/demo-tools/virtual-machines/AX2012DemoToolsMaterials

 

Enjoy to discover numerous new features included in this new version!

{ 0 comments }

During customization in Dynamics we usually check that what data store in Tables. For this I am more found of using SQL server then using table explore in AOT.  When we upgrade code from Dynamics Ax 2012 to R2, We found that many tables did not appear in SQL Server. Examples are EcoResProduct , BankLCImport and BankLCImportLine table.

It is not recommended by Microsoft to bypass Dynamics Ax 2012 and direct query on tables in Sql server. But sometimes it is requirement to get data direct form Sql Server. We finally found that if we build view in Dynamics on those tables either by creating Queries or by directly on table. These views are available in SQL Server. We can use that custom View in our query instead of tables in Sql server.

{ 0 comments }

Yesterday, I got error when I run the view which created on “” table  in Dynamics Ax 2012

9-9-2014 12-20-34 AM

“You are not authorized to access table ‘VBankLCImport’ (VBankLCImport). Contact your system administrator”.

Error was misleading because in development environment User have full access rights. And this error is not appear while running any view.

I also reset the license key, but problem does not resolve.

Finally it revealed that this error appear due to no field is added inside the view. I select the one key and drag and drop on fields in view section. Then right click on view. It successfully show me the values.

9-9-2014 12-21-42 AM

{ 0 comments }

Currency exchange rate setup in Dynamics AX 2012

by alirazazaidi on September 4, 2014

 

We can create transaction entries in different currency. For Example default currency set of Legal entity is “USD” and we have to create Purchase Order in Pak Rupees.

For this purpose we have to create exchange in Dynamics Ax.

The link of currency exchange is Ledger module, in Setup section and under currency. You can saw it as follow.

Link

 

Click on Currency exchange rates

 

Empty Selection

Select “Default” from Exchange rate Type. By default application exchange rate from “Default”. And then click on New Button, from right pane select From Currency to USD and To Currency select PKR.

By Default From date Set to “Current Date” and To Date set one month to after current Day. You can modify it as per your requirement.

In current scenario 1 USD is equal to 150 Pak rupee.

Date

There is also Start Date which is used as effective date, It means, between from date and to Date we can use multiple exchange rate.

 

Now you can create Purchase Order in Pak rupees, The Values are automatically converted into Pak rupees.

To verify that we create two Purchase order first in USD and second one in Pak rupees and verify that Item price are came in different values.

 

First we create Purchase Order with USD dollar and then create PO with and see the purchase Item price.

PO with USD dallor

 

Purchase Price

Now we create Purchase Order in Pak rupees and see the unit price.

PakRuppee

 

Purchase Price in PakRuppee

{ 0 comments }

How to Use AX Form As lookup in Dynamics Ax 2012

by alirazazaidi on August 27, 2014

Consider a scenario where, I required a StringEditControl and Clicking on Control a lookup is open where the list of Customer of selected Legal Entity are available. And After Selecting required Customer, Customer Id Or AccountNum is return form Lookup form.

 

For This purpose we have to create form, which will used as look Up.


Create a New form. Name It  “FormCustomerLookUp”

New Form

In Data Source Create and New dataSource Name It CustomerTable and Point to CustTable.

 

Customer Table As DataSource

Expand the Design node  and Right Click on It and Add Grid, Now from CustomerTable Data Source, Drag and drop “AccountNum” and “Party” on Grid. It will create two String Edit Control on Grid bound with CustomerTable.

 

CustomerFields

Now Select on “StringEdit:CustomerTable_AccountNum” select Properties. Form Properties window Set Its Auto declaration  property to True.

 

LookUpFieldAutoProperties

Now expend the Methods Node form and Right click and override the Init method from there and add following line of code there.

 

    element.selectMode(CustomerTable_AccountNum);

 

LookUpFormInitialization

 

 

Now right click on Design Node and Update following properties.

Width=360

Style=LookUP.

StyleToLookUp

 

 

 

Now Create a form where this lookup will use. For this Article I have to create very simple form with only on stringEdit textbox.

On its Design Right click and create StringEditButton with Name “LookUpTest” and from Its property window Auto Declare Property is set to Yes and lookupButton property to “Always”.

 

TargetFieldProperties

 

LookUpFields

 

 

 

 

 

 

 

 

Now Add two method, One used to Register control with Lookup, and Second method will use to call lookup form and gets its value.

protected void configureCustomerLookUp(FormStringControl stringControl)

{

if (stringControl)

{

 

 

stringControl.visible(true);

stringControl.registerOverrideMethod(

methodStr(FormStringControl, lookup),

identifierStr(CustomerLookUp), this);

 

}

}

LookupRegisteration

 

 

 

Second method will be called on lookup button click

 

 

private void CustomerLookUp(FormStringControl stringControl)

{

Args args = new Args(identifierStr(FormCustomerLookUp));

FormRun lookupFormRun;

 

args.parm(“”);

args.caller(this);

 

lookupFormRun = ClassFactory::formRunClassOnClient(args);

lookupFormRun.init();

 

stringControl.performFormLookup(lookupFormRun);

lookupFormRun.wait();

 

 

}

LookUpMethods

If you have already some knowledge above code is easily Understanable, where  Ax form Name set in args and instance of from is created at runtime and then attached the form to string controls performLookUp method.

 

 

 

Now run the form. And click on lookup button on textbox.

TargetButtonForm

 

Click on LookUp Button

 

 

LookUpClick

Selected Value will show on text box when you click on lookup grid

 

SelectedValueInTarget

 

 

 

Nice Experiments, Now you can use This functionality as you want,

 

 

 

{ 0 comments }