Dynamics Search Engine

Monday, October 29, 2012

How to fix Best Practice error The Table.Field does not have a corresponding parm-method on the AxBC-class


How to fix Best Practice error The Table.Field does not have a corresponding parm-method on the AxBC-class

Applied on:
Microsoft Dynamics® AX 2012 Fpk.

Assumption:
This article is for those who has at least basic and programming
knowledge of Dynamics® AX.

About this article:
how to fix Best Practice error The Table.Field does not have a corresponding parm-method on the AxBC-class  when you create new field for existing table. E.g. InventTable, PurchTable, SalesTable etc.
BP Deviation for The Table.Field does not have a corresponding parm-method on the AxBC-class due to new field creation for tables. 

There are number of ways to achieve this. As per my view the easiest way is to execute a job. A sample job is mentioned below.

static void CreateAxBCParmMethod(Args _args)
{
    axGenerateAxBCClass axGenerateAxBCClass;

    axGenerateAxBCClass = AxGenerateAxBCClass::newTableId(tablenum(InventTable));
    axGenerateAxBCClass.run();

}

In the above job you can replace the table name instead of InventTable to create parm method as per your requirement.
The above job will generate method against new field created for InventTable.
Hope this article is useful.

 

Thursday, June 14, 2012

How to use Windows File Path Dialog in Microsoft Dynamics® AX 2012

How to use Windows File Path Dialog in Microsoft Dynamics® AX 2012


Applied on:
Microsoft Dynamics® AX 2012 CU2.

Assumption:
This article is for those who has at least basic data flow, navigation and programming
knowledge of Dynamics® AX.

About this article:
This article may answers your question like-
In Microsoft Dynamics® AX 2012 how to call Windows File Path Dialog?
How to use Windows File Path Dialog in X++ language?
How to call WinAPI from Dynamics AX using X++ language?
How to take file path input from user?


I have written a job mentioned below which shows how to use Windows File Path Dialog with New Folder button option.


static void CallWinFilePathDialog(Args _args)
{
    FilePath filepath; // To hold path value
    filepath = WinAPI::browseForFolderDialog("Description goes here", "Selected path goes here", true);
    info(FilePath); // To Display
    // Here you can use your TableName.FieldName = filepath to store the value.
}

The above code execution displays below dialog:



You can create a button called Browse and implement above code to its clicked method.

Sunday, May 27, 2012

How to use Event Handler in Microsoft Dynamics AX 2012

How to use Event Handler in Microsoft Dynamics AX 2012

Applied on:
Microsoft Dynamics AX 2012 CU2.

Assumption:
This article is for those who has at least basic data flow, navigation and programming
knowledge of Dynamics AX.

About this article:
This article may answers your question like:-

• In Microsoft Dynamics AX 2012 how to handle event on different methods / occurrences.

• In Microsoft Dynamics AX 2012 how to implement or apply pre or post event handler.

• How to develop an event handler step by step in Microsoft Dynamics AX 2012.

• What is new in Microsoft Dynamics AX 2012 from programming point of view.


• X++ Event handling in Dynamics AX 2012.



Microsoft incorporated lot of beautiful new features in Dynamics AX 2012 and one of them is Event Handler. It’s a very nice feature of Dynamics AX 2012 which allows you trigger an event after or before an activity.

There are different programming paradigms like:
Observation: Where based on a particular behavior occurrence events can be used. For example if a new customer is created, based on this you need to update a table record and intimate to user.

Information dissemination: This is related to trigger an event at right time, right information to get expected result.

Decoupling: One producer's event can be acted upon by any number of consumers. Consumers can act upon any number of events from many different producers.


You should locate natural customization points and use events to publish the relevant information to subscribers.

You should invoke / defining events over using pre or post events on methods.

Pre-Event Handlers and Post-Event Handlers

An event handler can reside underneath a method node can run either before or after the method runs. You can use CalledWhen property on the event handler node. The CalledWhen property has two values:

• Pre – The event handler runs before the method starts.
• Post – The event handler runs after the method ends.

A new class the XppPrePostArgs Parameter is being used by event handlers.

A pre-method event handler that has only an XppPrePostArgs parameter can inspect and change the values of the parameters.

Similarly a post-method event handler that has only an XppPrePostArgs parameter can inspect and change the return value from the method.


When an XppPrePostArgs object is used, the values of the parameters and the return type can be changed by the event handler. The values can be changed even if the parameters and return type are value types, such as an integer or string. If a parameter or a return type is a reference to an object, the event handler can call methods on the object and could change the state of the object.


Event handlers can run only on the same tier as the publisher class of the delegate runs on. For instance, if the publisher class has its RunOn property set to Server, to declare a method with client keyword and call a subscribed event handler method is not allowed.

You can use X++ event as well as .Net made managed code event. You can define it at Event handler proper called EventHandlerType.


How to use event handlers in Microsoft Dynamics AX 2012 step by step:

1) Open your new developer work space and go to AOT then classes node.

2) Right click on Classes node and click on New Class as shown below.


3) By default system will give a name to it. Here in my case it’s Class1. Right click on newly created class and click on Rename shown below.


4) After clicking Rename, give a name called CustTableEventHandler to it. Here I am going to develop an event to be applied on CustTable so that is the reason why I decided this name (CustTableEventHandler). After renaming this class, it looks as shown below.


5) Right click on class CustTableEventHandler then New then Pre- or post-event handler as shown below.


6) Once you click on this, system gives you a method as shown below.


7) Customize the method as shown below.

8) Here args is providing current record to custTable instance and info is displaying the current customer account. The code snippet is below.

public static void custCreateInfo(XppPrePostArgs _args)
{
     CustTable custTable;
     custTable = _args.getThis();

     info(strFmt("Customer account %1 has been created", custTable.AccountNum));
}

This method I support to call from insert method of CustTable with type post event. It means that once insertion is done to CustTable, system will display recently inserted customer account number. It depends on your business requirement what logic you want to apply here. So here you can develop your required business logic or invoke pre built logic.

9) Go to Tables node in AOT then find out CustTable.

10) Go to insert method of CustTable and right click on it then click on New Event Handler Subscription as shown below.


11) After clicking you will get a new Event handler shown below.


12) Rename the event handler to custCreateInfo and set the property as shown below.


13) Now save your work.

14) Go to Customer form and create a new customer. Here I created a new customer account called “Test-000001”.


15) Once this customer is created system will give your infolog as shown below.


Hope this will help you to understand the event handler in Microsoft Dynamics AX 2012.

Friday, May 11, 2012

Microsoft Dynamics AX 2012 Cubes or Role center BI report error

Microsoft Dynamics AX 2012 Cubes or Role center BI report error.

In Microsoft Dynamics AX 2012 you might face problem with BI reports for role center or reports where Cubes are involve.

There can be number of reasons for this and you will get number of errors. Like permission not granted, access denied, related data missing, cubes not processed etc.

Two main reasons are (1) data missing in respective tables and (2) insufficient license.

In most of the places data is interrelated among the tables. If you are missing related data in tables, it will give some errors.

Secondly, by default Microsoft provides cubes for all the tables and assumption is you have 100% license. But when there is a limited license and you apply it to your application, based on limited license system drops few tables for which you do not have license. In such a scenario your queries for cubes are not updated and they are still using 100% tables but you don’t have 100% tables now because of limited license.

Here the option for you is to update the queries but it’s a huge task. For Microsoft Dynamics AX 2009 you have to do it manually but to help you Microsoft published a tool to generate an excel sheet which tells you what are the areas you need to work.
In case of Dynamics AX 2012, Microsoft provided few options in the form of a wizard from where you can do it by clicking a button as shown below:
Path: Tools Business Intelligence (BI) Tools  SQL Server Analysis Services project wizard.

In the above wizard if you select Update option and follow the wizard it resolve your problem.

Saturday, April 14, 2012

How to open record directly from Info dialog in Microsoft Dynamics AX 2012

How to open record directly from Info dialog in Microsoft Dynamics AX 2012


Applied on:
Microsoft Dynamics® AX 2012 CU2.

Target audience:
This article is for those who has at least basic knowledge of X++ programming.



About this article:
During AX customization most of the time when you create / update / manipulate record, in general the record we display in an infolog to inform end user. It’s easy for end user to open and see the record from info log dialog using a show button or by double click on the message.



This article can answers for below question:

How to display Show button on info log dialog in Microsoft Dynamics® AX 2012?Double click on info log message and open the record in Microsoft Dynamics® AX 2012.Pass record to the info method, display Show button on info log dialog and open the form with current record in Microsoft Dynamics® AX 2012.Directly open record from info dialog / form in Microsoft Dynamics® AX 2012.


Below is job which shows a vendor account in info log dialog and if you double click on the vendor account number it will open the vendor account detail form.

Job:




Info log:


Tuesday, February 21, 2012

In Microsoft Dynamics AX 2012 during data import using Excel Add-Ins you may experience an exception or error

In Microsoft Dynamics AX 2012 during data import using Excel Add-Ins you may experience an exception like: “You must include at least two items in any list used for updating data.”

Applied on:
Microsoft Dynamics AX 2012 CU2.

Assumption:
This article is for those who has at least basic data flow and navigation
knowledge.

About this article:
This article may answers your question like-
• In Microsoft Dynamics AX 2012 how to handle exception during data import or data conversion?
• In Microsoft Dynamics AX 2012 how to copy master data from one environment to another environment and handle exception or error?
• In Microsoft Dynamics AX 2012 what are the new feature to export / import data?

Exception:

Resolution:
During data import using Excel Add-ins tool you need to select table(s). Once the table(s) is selected, by default system will select field(s) from table which is mandatory or part of primary index. If you have more than two fields like this then you will not face this exception or error. If there is one field which is mandatory or part of primary index in your table then system will select that field and put in the excel sheet and manually you need to select one more field along with this. In the above error screen if you see the red marked area where one more field to be added to get out of this exception.
Hope this is useful.

Wednesday, January 4, 2012

In Microsoft Dynamics AX 2012 how to copy configuration and setup data from one environment to another environment.

In Microsoft Dynamics AX 2012 how to copy configuration and setup data from one environment to another environment.

Applied on:
Microsoft Dynamics AX 2012 CU2.

Assumption:
This article is for those who has at least basic data flow and navigation knowledge.

About this article:


This article may answers your question like-
• How to copy a legal entity from one environ to other environment? For instance; development environment to test environment, test environment to user acceptance training (UAT) environment, user acceptance training (UAT) environment to pre production environment, pre production environment to production environment etc.
• In Microsoft Dynamics AX 2012 how to copy configuration or setup data from one environment to another environment?
• In Microsoft Dynamics AX 2012 how to copy master data from one environment to another environment?
• In Microsoft Dynamics AX 2012 how to copy transaction data from one environment to another environment?
• In Microsoft Dynamics AX 2012 what are the new feature to export / import data?
• In Microsoft Dynamics AX 2012 how to use definition group?
• Is it possible to use duplicate company data for testing in Microsoft Dynamics AX 2012?
• In Microsoft Dynamics AX 2012 how to export and import configuration?

Microsoft recommends that you use the Microsoft Dynamics AX data export and import feature to support scenarios that previously required in AX 2009 the duplicate company feature. Means there is no button which you will press and system will create a duplicate company for you. But what about configuration data export and import?

In Microsoft Dynamics AX 2009, the duplicate company feature was used extensively to copy data from one company to another. The feature was also used to build development or test environments, UAT, Preproduction and deployment scenarios that moved data from one environment to another. For example development to test environment, test environment to UAT environment, Pre production to Production environment etc. However this feature became obsolete in Microsoft Dynamics AX 2012.


In Microsoft Dynamics AX 2012, company or data area is not a part of data security boundary and the new thing Microsoft introduced is organization model where data is not related to a company or legal entity. At table level there is property called SaveDataPerCompany which is the replacement of company concept. If you set this property to Yes, you hold company specific data in table.
How to copy a legal entity from one environment to another environment?


Following are the steps to use an existing legal entity as a template for other legal entities.
1. Create a legal entity to use as a template.

2. Set all configuration data for the source legal entity.

3. Create a definition group which can be used to export data.
a) To create a definition group, open your AX client. Go to System Administration module->Common->Data export/import->Definition groups->Click on New button or Ctrl + N. On General tab of Create table definition group form, provide your Definition group and Description.


b) On Options tab of above form check Include shared tables check box as shown below.

You should not check Include system tables check box, Include database log tables, Include cross-reference tables. For example if you include system tables it may stop you to access AX client.

c) This part is important: To export configuration data, include the following table groups: Reference, Parameter, Group, Framework, and Miscellaneous as shown below.


d) To export master data, you must include the tables that are in the Main table group.

e) Do not include the tables that are in the Transaction, Transaction header, Transaction line, Worksheet, Worksheet header, and Worksheet line table groups. These tables include transaction data. It can be difficult to create a duplicate environment for transaction data if the SaveDataPerCompany property of tables is set to No. For transaction date Microsoft SQL Server backup and restore mechanism is one of best option but a minor configuration changes can be made to illustrate specific Microsoft Dynamics AX features.

f) Now click on OK button to create definition group.

4. Now you are ready with Definition group to export data for a legal entity (Company). Go to System Administration module->Common->Data export/import->Export to. Select your Definition group from drop down and provide the file Name (and location). Remaining things are up to your choice. Clock on OK button. This will create a .dat file with your given name using the Microsoft Dynamics AX data export and import feature to export the legal entity to a .dat file.


5. In the new environment, create new legal entities, and then import the .dat file that you created into each entity individually (in step 4). Go to System Administration module->Common->Data export/import->Import. Select your Definition groups from the drop down and provide file Name (and location). Remember if you have different environment create a same definition group in your new environment where you are support to import data for a legal entity. On Advance tab there are different options but you may go for Include shared tables.

Shared and per-company data is imported. When other legal entities are subsequently imported into the new legal entities, the shared data is merged.

NOTE: Please use at your own risk. There is no warranty on this article.