Showing posts from July, 2011

Dynamics AX 2012 - The AutoRefreshData property on buttons

In yesterday's post , we learnt about the NeedsRecord property on buttons. This is a new property introduced in Dynamics AX 2012. Today we will learn about another new property on buttons in Dynamics AX 2012 - the AutoRefreshData property. So what does this property do? The help text for the property says " If yes, the data in the datasource associated with this button is refreshed after the button is clicked. " Well that explains it. With this property on, any datasource associated with the button is refreshed when the button is clicked. Consider a scenario, where on clicking a button, an edit form opens and allows the user to edit certain field values. After the form is closed, the values in my master form will auto refresh. My initial assumption was that setting the AutoRefreshData property will eliminate the need to explictly call refresh/research after a button was clicked. I found out that this isn't the case and I was wrong . Let us look at this in more detai

New feature in Dynamics AX 2012 - NeedsRecord property on Buttons.

In Dynamics AX 4.0 and 2009, if a button's action depended on a record being present, we usually added code in the executeQuery() method of the datasource to check for the existence of a record. If a record was not found, the button was disabled. Scenarios like these required specific code to be written by the developers. With Dynamics AX 2012, this has change. There is a new property NeedsRecord introduced on all button controls, these include your plain buttons, menu item buttons and command buttons as well. Menu button groups do not have this property. The NeedsRecord property works in conjunction with the DataSource property. Now we know that the normal buttons and command buttons do not have a DataSource property? So what happens in that case? The answer is the DataSource property is inherited from the parent of the button. This could be a button group or a tab page. If the button group also doesn't have the DataSource property set, then the kernel looks for the next pa

How to check project budget amount through code in Dynamics AX 2012?

In my earlier post, I had shown how easy it is to enable budget control on projects. You can read that here . I got a couple of questions on it and I thank my readers for the interest. I found one of the question to be very generic and the scenario described was something which many customers may be doing. The scenario given was, The customer creates a lot of project transactions on a daily basis but posting of them is done through a batch only on the month end. So the customer has allocated an approved budget of 1000. We have 20 journals each with an amount of 100. Now we post these journals in a batch. So, after posting 10 journals, the whole budget will be exhausted. So from the 11th journal onwards, we will be receiving an error that budget will be exceeded by 100. Now the question was, is there any way to know before hand while creating the transaction that there isn't a sufficient budget and hence the transaction will not be posted. Well, it surely can be done with a little c

Hands on - How to enable budget control on projects in Dynamics AX 2012?

In Dynamics AX 2009, there was no out of the box support for budget control. That has changed in Dynamics AX 2012. We now have a ledger budget control framework which is nicely integrated with the other new frameworks in Dynamics AX 2012. The Project management and accounting module has built in budget control support. We just need to configure the budget parameters, allocate and approve an amount and the framework takes care of the rest. In this post, I'll walk you through how to activate budget control on a project. Open the projects list page by going to Project management & accounting -> All projects Create a new project by clicking the new button and enter the following values as seen in the image. We will have to enable budget control on the project. To do this, expand the Budget and forecast tab. Select the Use budget control check box, set Budget overrun default field to Disallow overruns. Set the project stage to In process. To do this, select In process from the

How table and class customizations are stored in UtilElements?

In my previous article on finding all the layers on which an object has been modified, I explained how the UtilElements system table can be used for this. You can read that post here . Some of my readers mailed me asking that they were not getting the correct results when querying the UtilElements table. I clarified what the issue could be. This post will discuss further on the UtilElements table and what are the things one need to be aware of when querying this table. Let us first see how table customizations are stored in the UtilElements table. Let us take the Address table as an example. On my system, I have just added a comment in the axAddress() method. As you can see in the below image, the table is shown as existing on the usr layer and you can also see the actual changes. Now I'll query the UtilElements table where name is Address. while select utilLevel from utilElements where == tableStr(Address) && utilElemen

How to toggle button states using the FormButtonManager class in Microsoft Dynamics AX 2009?

Generally in Dynamics AX, we write seperate methods for controlling the state of buttons on forms and call these from the data source's active method. In Dynamics AX 2009, a new framework was introduced for this need. This is the FormButtonManager class. This class provides all the necessary methods to tap into this framework and control the state of the buttons. The idea is similiar to what we are used to do but this class provides a more clean approach. Let us take a practical approach to using this framework. We will work on the Customers form (CustTable). On the Customers form, we have a menu button named "Project Control". Now the requirement is that this button should be enabled only for customer's who are associated with projects. Now we need a provider class to provide us with the various rules which control the button states. For this purpose we will have to create a class. Each rule is created as a method in the class which returns a boolean value represen

Quick tip: How to find your security identifier(SID) on your system?

Whenever we restore our Dynamics AX database, we have to update the UserInfo table to set the correct NetworkDomain, NetworkAlias and the SID fields. Most of us have a simple SQL script which we run whenever we need this. You may know the network domain and alias values but finding the SID value can be difficult. Well, the SID value or Security IDentifier value is a unique ID by which your system is identifier by other systems or network domains. This value is stored in the registry. Open the Windows registry by typing regedit in the run menu and navigate your way to HKEY_CURRENT_USER\Software\Microsoft\Protected Storage System Provider\S-X-X-XX-XXXXXXXXX- XXXXXXXXXX- XXXXXXXXXX-XXX This is where you can find the SID of your system. Hope this helps.

How to get a list of all the layers on which customization has been made?

In Dynamics AX 4.0 & 2009, all layer customizations are stored in AOD files. In Dynamics AX 2012, the AOD files have been replaced by SQL model data store. Sometimes, a developer may want to know what all layers a particular object has been customized on? For this, there are two possible solutions available. Querying UtilElements table Using TreeNode class The UtilElements system table can be considered a representation of the AOD file in a table format. We can query any kind of information like, which layer an object has been customized, what has been customized, the source code for an object on a particular layer, the number of times an object has been saved, who created or updated the object etc. The advantage of using UtilElements is that it is extremely fast. The second approach is using the TreeNode class. The method applObjectLayerMask() returns an integer whose value is a bitwise representation of all the layers on which the object has been customized. Let us look at t

How to set focus on a control on a form that has been opened through code?

The other day, a question came up if we can open a form through code and focus on a particular control? Well, we surely can easily do that. The setFocus() method is commonly used to put the focus on any control. The question was to put focus on a control on a form which was open through code. The solution is to first get a reference of the control on which you want to set the focus and then call setFocus on it. The FormDesign class has a method controlName() which will return us the control. It takes a string argument. The below code shows us how to do what we just discussed. static void setFocus(Args _args) { Args args; FormRun formRun; FormControl formControl; ; args = new Args(formStr(Address)); formRun = classFactory.formRunClass(args);; formRun.detach(); // Get a reference of the control we want to set focus on formControl =; formControl.setF

Employee self services feature demo in Microsoft Dynamics AX 2012

The Employee self services portal in Microsoft Dynamics AX 2012 is the centralized location for all employees of the organization to go about performing common tasks. Employees can order products, submit their expenses, approve expense reports & other documents or navigate and submit their timesheets. There is a video available on this here Go check it out and share your thoughts.

Dynamics AX 2012 Pricing and Licencing information

The Dynamics AX 2012 Pricing and Licencing information in draft format is now available on partner source here (Partnersource credentials required)

Microsoft Dynamics AX 2012 global virtual launch event

The Microsoft Dynamics AX 2012 global virtual launch event is scheduled for Thursday, September 8th. The event is a global platform for Microsoft executives, customers and partners to come together and speak, listen, give product demos and watch product tours specific to business or industry. You can find more details and the registration link here

How to fix - "Illegal data conversion from original field" errors

At one time or another, most of you must have come across one or both of these errors, Case 1: Illegal data conversion from original field Table1.FieldX to Table2.FieldY: Unable to convert data types to anything but character field type (0 to 4). Synchronize database Cannot execute the required database operation.The SQL database has issued an error. Case 2: Illegal data conversion from original field Table1.FieldX to Table1.FieldY: Unable to convert data types to anything but character field type (0 to 4). Synchronize database Cannot execute the required database operation. The SQL database has issued an error. The difference between these are that in the first case, the tables as well as the fields are different whereas in the second case the tables are same but fields are different. Now, there are two scenarios when you may encounter the above error. While upgrading from one version of Dynamics AX to another version While importing a project or a stand alone xpo These errors state t

How to read Excel 2010 worksheets using the CCADOConnection class?

In my previous post, I showed how we can read Excel worksheets in Dynamics AX using ADO wrapper classes. You can read that post here . Well, the connection string used in the example will work only with Excel 97-2003 worksheets. If you try to open a Excel 2010 worksheet using the connection string in that you will get an error. The reason for this is that the Excel 2010 format is the Office Open XML format and hence requires a different connection provider to connect to. This provider is the Access Database Engine component. So we should modify our code slightly to make this work. Now the connection string will be,"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + ExcelFile.text() + ";Extended Properties='Excel 12.0;HDR=No;IMEX=1'"); This should let you open Excel 2010 worksheets as well. While running this code, you may encounter any one of the following errors Method 'open' in COM object of class 'ADODB.Connection' retur

Reading Excel worksheets in Dynamics AX using CCADOConnection, CCADOCommand & CCADORecordSet classes

Recently I came across Bojan's post on performance improvements using CCADOConnection, CCADOCommand & CCADORecordSet classes for reading Excel sheets. You can read the original post here . Well, there is a minor change in the CCADORecordSet class in Dynamics AX 2009 compared to Dynamics AX 4.0 which most users should be aware of. But I thought of still documenting it here. The CCADORecordSet.moveNext() method isn't present in AX 2009 anymore. To move to the next recordSet, we should use adoRecordSet.recordSet().moveNext(); void readExcelSheet() { CCADOConnection adoConnection; CCADOCommand adoCommand; CCADORecordSet adoRecordSet; CCADOFields adoFields; CCADOField adoField; int i,j; ; adoConnection = new CCADOConnection(); adoRecordSet = new CCADORecordSet();"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ExcelFile.text() + ";Extended Properties='Excel 8.0;HDR=No;

Replace text option in Find window in Dynamics AX

Recently, I was involved in upgrading a Dynamics AX 2009 project on roll up 5 to roll up 7. I had the need to replace some comments in the code with a different format. I did a Find on the project and the total count came to 2000+ hits. The Find & Replace option in the editor only works on the current method open in the editor. In my case, there were multiple methods in the same object which needed the code to be replaced. Manually moving between the methods and doing a Find & Replace all would have been time consuming. My other option was to export all the objects as an xpo outside and do a Find & Replace all in notepad. The problem here was that these objects were distributed among several projects. Finding them and putting them in one project would take some time. Then I thought why not create a small tool which can do this for me. I thus added a Replace tab in the Find window in Dynamics AX and used it. All my 2000+ find instances were replaced instantly. I thought