Creating a Visual Interface for AX2012 Model Importing

29 03 2012

For those of you who have been working on AX 2012 and have been using the AXUtil tool for importing, exporting and deleting models, you’ve probably run into a significant amount of frustration. Leading to the inevitable question: Why didn’t AX2012 ship with some sort of visual interface to accomplish Model management?

Although I cannot answer this, I can, for those of you who are interested in getting your hands dirty with a bit of C# code, point you in the right direction of how to build your own interface with relative ease.

Recently i discovered a handy little dll that really makes writing a model management program a breeze. Its located at: C:\Program Files\Microsoft Dynamics AX\60\ManagementUtilities\AXUtilLib.dll. This inconspicuous dll exposes all the functionality of the AXUtil.exe program directly to the developer. For example to delete a model (in a C# application):

AxUtilContext context = new AxUtilContext();
 AxUtilConfiguration config = new AxUtilConfiguration();
 config.Server = 'SQLSERVERNAME';
 config.Database = 'DATABASENAME';
 string modelName = 'TestModel';
 if (modelName != "")
 if (MessageBox.Show( "Are you sure you wish to delete model " + modelName + "?","Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
 config.ModelArgument = new ModelArgument(modelName);
 AxUtil util = new AxUtil(context, config);
 util.Delete(context, config);

 if (context.HasError)
 MessageBox.Show("Failed to delete model " + modelName, "Error", MessageBoxButtons.OK);
 ICollection<String> errors = context.Errors;
 IEnumerator<String> enums = errors.GetEnumerator();
 while (enums.MoveNext())
 MessageBox.Show("Model Deleted", "Model Deleted", MessageBoxButtons.OK);

You can use the AXUtil class to do your import, export, get a list of all installed models etc…
Below is a quick demo of an application I wrote to do basic importing, listing and deleting models.

Please leave some comments if you have had the chance to explore this

Update: On request here is my demo project for the above (will probably require some tweaking to get it to run on your machine, but the code is there). Note: This is only experimental. DOWNLOAD

Update: Download the binary version of this project. Includes meta data renaming and parent model creation). This is shipped with no warranty whatsoever. DOWNLOAD (Last updated 18 April 2012)




7 responses

12 04 2012
Shashi Sadasivan

Hi Jonathan,
Do you have the application available for download?
I have created an app (C#) to export the models so far, was about to implement (nearing stages where i could possibly start the import; But you beat me to it.

12 04 2012

Hi I’ve attached my sample project, its really just and experiment for the moment so you will need to fill in the gaps where it comes to license files, certificates etc, but all of that seems to be available in the DLL.

12 04 2012
Shashi Sadasivan

Page not found on the link ! :D

12 04 2012

Sorry about that, it should be fixed now.

12 04 2012
Kurt Hatlevik

Nice Jonathan. This can reduce our fustration. Looking forward to see the continued development of this nice tool.

31 05 2012
Jan B. Kjeldsen

Also see this GUI:

It contains less parameters, and may be easier to use.

31 05 2012

Very nice tool and useful on client sites. Having it within AX though has some limitations. I prefer having a tool like this outside of AX as I export our devs from a Dev environment to a a Sandbox environment to see if this functionality is shippable, thus I’m having to work with multiple model stores. I guess it would be possible to extend this tool to also connect to other DBs…

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: