Working with model in AX 2012

How to: Export and Import a Model AX 2012

 Run:  enter: Cmd >> go to specified path C:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin

Type the following command:
// creating the Model in the Layer
AxUtil.exe  create /model:"Name" /Layer:CUS

// exporting the model to file
AxUtil.exe export /model:"NAME" /file:"Name".axmodel

// importing the model from file
AxUtil.exe import /file:Name.axmodel 
>>  /config:instanceName ( import to correct AOS)
>> /createparents (in case of conflicting with system model)

// delete the model
AxUtil.exe delete /model:"Name"
or  AxUtil.exe delete /model:<model working id>

//delete the layer
AxUtil.exe delete /layer:ISV

// if you have multiple instances running
//delete the layer from the database and AXserver.
AxUtil.exe delete /layer:ISV /db:<database> /s:<server>

// full compile from AX2012 CU7 AxBuild:
axbuild xppcompileall /s=01

or
Axbuild xppcompileall /aos=01 /log="E:\log" /altbin="C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin" /compiler="C:\Program Files\Microsoft Dynamics AX\60\Server\AX2012R2\bin\ax32serv.exe"

















AxBuild.exe can accomplish a full compile of all X++ code, into AX p-code, many times faster than the traditional compile that you start from the MorphX client menu.


How to deploy Dynamics AX2012 reports:
  1. Through AOT
    AOT > SSRS Reports > Reports > right click on report > Deploy Element
     
  2. Through Visual Studio
    Open the report project > Right click on the project or solution node > Deploy
     
  3. Through PowerShell
    Publish-AXReport -ReportName *

Step by step: import layer without losing data

Step 1. Create a model and move all the objects that you want to move out of the layer.
Tool > Model Management > Create model

Step 2. Create a project of this model and export the project as an xpo.
Tool > Model Management > Create project from model

Step 3. Backup the database and delete the old model created in step 1

Step 4. Synchronize the database from the AOT. This will delete the data but we will retrieve it later.

Step 5. Import the xpo from step 2

Step 6. Synchronize the database.

Step 7. Export this new model.

Step 8. Restore the database that was backed up from step 3

Step 9. Import the new model (step 7), Synchronize and compile
This restores the I’d values of the objects and tables / fields. So no data will be lost

Step 10. Delete old model, compile / synchronize.

How to: Open Visual Studio with a Specific Configuration or Layer [AX 2012]

To Open Visual Studio with a Specific Configuration from a Shortcut

1.       On the client computer that is running Visual Studio, open the Start menu, right-click Visual Studio 2010, and select Properties.
2.       Update the Target field and add the /AxConfig switch with either the name of the client configuration or the name of the client configuration file as shown in the following examples:

"C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" /AxConfig z:\Config\ContosoDev.axc

If you run the Visual Studio executable with a parameter of /?, then it will show you all the available switches you can use.

Label
We now have a new node in AOT – Label Files

All labels in the system are grouped under this node.
Now suppose we have a label from another installation which we want to bring in to our system. Right click on the Label Files node and select Create from File. Browse and selct your .ald file. Once you select the file and hit OK, a new node is added under the Label Files node corresponding to the label file imported. You will get an info message saying “Imported label file:C:\Users\Administrator\Desktop\MyLabelen-us.ald”

In AX 2009, after placing a label file, we needed to restart the AOS so that the label index was build. This isn’t required in Dynamics AX 2012. Just try using the label somewhere, and you will see that it is immediately referenced.
If you search in your application folder, you wont find the label file there. The application folder is located here C:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin\Application\Appl\Standard
In Dynamics AX 2012, the label file is imported in your current model.
Now let us restart the AOS and see what happens. After restarting the AOS, go back to your application folder and try to find the label file again. This time the label file will be found.
Point to remember, on every AOS restart, all label files will be copied to the application folder from the model store. So your label files are contained in your models but they are stored in your application folder as well.
Now let us try to delete the label file. Right click on your label file. Do you see a delete/remove option?
The answer is no. So how do we delete the label file then? The solution which I figured out was,
To create a temporary model
Move our label file to the temporary model
Stop the AOS
Delete the temporary model
Start the AOS
Let us get about with these tasks
Go to Tools -> Model management -> Create model
Enter name as TemporaryModel. Press OK. You will recieve an info message saying “The model TemporaryModel was created successfully in layer var.”
Right click on your label file and select “Move to model”
Select the TemporaryModel checkbox and press OK.
Stop the AOS.
Open a command prompt. We will be using the command line utility AXUTIL to delete the model.
Issue the following command in the command promptAXUTIL delete /model:TemporaryModel
You will be prompted if you want to delete the model or not. Press Y
Start the AOS
Delete the label file from your application folder as well.

When you open AX now, you will get a dialog saying that “Your model store has been modified.” This is normal because each time you perform an operation on a model, you will get this dialog. Depending on your operation, you should select one of the option. Since we just deleted a model which just had a label file, select Skip.
Open AOT and notice that the label file is deleted now.