Saturday, 23 December 2017

Get Value of Selected Record from a Reference Group Control in Dynamics AX

Suppose you have a reference group control ReferenceGroupCtrl in your form and you have defined an EDT on it. Now you want to get its selected record value.

To get RecId of the selected Record, you can use,
ReferenceGroupCtrl.value()

To get Text of the selected Record, you can use,
ReferenceGroupCtrl.controlNum(1).valueStr()
where 1 is the first control inside a reference group

Thursday, 14 March 2013

List of objects not in Version Control in Dynamics AX 2012

Hello all,

Most of you would have been in a situation when you don't know which objects were not added in Version Control. It is really tiresome to go to individual objects and check whether we have added it or not.
Here is a simple job which will return a list of all objects that were not added in Version control system.



Description: 
The while select will loop through all objects that we need to include in the search. Then for the individual object, we check whether that object is part of Version control or not.
versionControl.allowCreate(treeNodeOfObjectToCheck) is a static method which take tree node as argument. It will return true if the object can be added in Version control otherwise false.

The above example will search complete Data Dictionary objects. To include more type of objects, just add a new condition in the where clause. The enum UtilElementType contains all the type of objects that exist in Dynamics AX 2012.

Further tweaking can be applied to this job. Suppose you don't need to search objects in all layers but the current layer in which you are working. It can be accomplished by adding another condition in the where clause.


The static method global::currentAOLayer() returns the current layer. The above condition must be added using the AND operator.

Feel free to ask if there are any queries regarding it :)











Monday, 15 August 2011

Using custom Image resource in Dynamics AX 2012

Dynamics AX 2012 allows developers to include their custom images in form‘s or report’s. However, to use this a little bit tweaking is needed. This blog will go through the steps to use a custom image in an AX form.


Adding custom resource to AOT:
First go to AOT à Resources. Right click resources node and select ‘Create from file’. Browse and select the custom resource. Rename the resource to ImageResource. The custom resource has been added.

Using the custom resource:
Create a New dynamics AX form, let say CutomResourceDemo. Add a window control in the form and rename it to CustomImage. Set its AutoDeclaration property to Yes.

Create a new method loadImage at the form methods node and write the following code:


Override the run method of the form and call the loadImage method after the call of super()

Run the form. The custom image has been loaded :)




Tuesday, 5 July 2011

Customized Lookup In Reference Group Control

This blog describes how to implement customized lookups in reference group control in Dynamics AX form.
Steps
  1. Add a reference group control on the form.
  2. Override the lookup method of the control and add the following lines of code 

  3. In the lookup form, override the closeSelect() method of the form and comment the super of the method.
  4. Two different situations may occur when selecting a record in the lookup form:
    1. If the reference group control’s reference field is contained in the lookup form’s parent data source, then pass that datasource buffer as a parameter to the closeSelectRecord() method.

    2. Otherwise, if the reference field is not contained in the parent data source, call a method on the calling form from the lookup form. For this, create a method on the calling form that accepts the buffer from the lookup form. In this method assign the passed record to the reference field. 

If anybody have any queries feel free to ask.