Wednesday, November 15, 2017

Dynamics 365 - UtilElements in AX 7

In older versions of Dynamics AX, you can get information about AX application objects (metadata) through system “tables” such as UtilElements. This doesn’t work anymore in AX 7. These tables still exist, but they don’t have any data, therefore you have to migrate to another solution.

AX 7 comes with a rich framework for metadata, implemented in several assemblies in namespace Microsoft.Dynamics.AX.Metadata. But it’s too complex for simple tasks – you can make it much simpler by using MetadataSupport class. For example, the following piece of code iterates through all form names:


var forms = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::FormNames();

while (forms.MoveNext()){    print forms.Current;}

Dynamics 365 - Service unavailable error when opening AX7 in web browser

We got this weird error just now. After a little digging around we found that the AOS service had stopped running... However, the AOS is no longer a Windows service.So here's how we fixed it:1) log on the VM that hosts the AOS2) open the IIS manager (click 'start', then type in 'iis', then click the 'Internet Information Services (IIS) manager'3) in the 'connections' pane on the left-hand side, drill down to the 'application pools' node and select it4) in the main windows (center of screen) look for the 'AOSService' and make sure its status is 'running'

Tuesday, November 14, 2017

Dynamics 365 - How to open standard AX Attachments dialog with a different caller or source record

Standard AX Attachments dialog always looks for the caller form's primary data source and displays all the attachments related to this (if available). 

But my requirement is to link a form which has a view or a table as a non-primary data source and  open the Attachments dialog for it.

We can achieve this by doing 1, 2 and 3


1: If the table/view is not added yet as datasource, then add it to the form as a data source and join it with the primary datasource, if it is not the primary itself.

2: Set the OnlyFetchActive property of this data source to Yes so that it only fetches recIds from the database hence minimizes the impact on performance. 


3: Override the docCursor() method of the form and return the table/view buffer.


Thats it!!

Dynamics 365 - Making dialogField as the first field on a dialog - Using Extensions


Recently I got a requirement where I need to add a field to a dialog from a class extending RunBase. I could do it by writing a post event on Dialog method . The post event calls a method on extension class which adds the field.

dfObjectId = _dialog.addField(extendedTypeStr(myEDT));


However this field was always added at the end of the Dialog which the end user do not want as they wanted this dialog field to be the first field on the dialog. I could achieve this by the following piece of code which I added just after the dialogField is added


// Move the Object Number to the top on the Dilaog
control = dfObjectId.control();
parentControl = _dialog.mainFormGroup();
parentControl.moveControl(control.id());

Here is the final code in my extension class method which was called by the post event on dialog method, 


public void myDilaog(Dialog _dialog)
{
    FormBuildControl control;
    FormBuildGroupControl parentControl;
    dfObjectId = _dialog.addField(extendedTypeStr(myEDT));


    // Move the Object Number to the top on the Dilaog
    control = dfObjectId.control();
    parentControl = _dialog.mainFormGroup();
    parentControl.moveControl(control.id());
}



Thats it!!

Dynamics 365 - Find all newly created AOT objects that are not added to the Source control (Version control)



It happen sometimes that we forget to add our changes to the version control system and at one point we don't remember what we have changed in the past. Dynamics 365 comes with a  simple "Add Items to Folder" tool, which will help us find all the missing objects and add them to source control.

In order to accomplish this, please follow the step by step guide,


Goto Team Explorer>Source Control Explorer'

















Navigate to '$/YourVSProject/Trunk/Main/Metadata' and click on 'Add Items to Folder' button on the top left



Select the Model folder (E.g. MyModel) and click 'Next' to choose from the list of objects which are not added to Version Control. Or 'Finish' to add everything missing from Version Control.

This will check all the objects missing from source control and are available in the 'Local repository' and adds them to the pending changes list.

That it!!!