Thursday, September 24, 2015

How to List Models in a Model Store in AX 2012

List models (Windows PowerShell) :-

1.To list the models in a layer, at the Windows PowerShell command prompt, PS C:\>, type the following command, and then press ENTER.

      Get-AXModel -Layer <LayerName>

2.To list the models in the model store, at the Windows PowerShell command prompt, PS C:\>, type the following command, and then press ENTER.

   Get-AXModel


List models (AXUtil) :-

  1. On the Start menu, click Command prompt.
  2. Navigate to the directory for the management utilities. Typically, the location of this directory is %ProgramFiles%\Microsoft Dynamics AX\60\ManagementUtilities.
  3. To list the models in a layer, at the command prompt, type the following command, and then press ENTER.
        axutil list /layer
        :<layername> 

    4.To list the models in the model store, at the command prompt, type the following command, and then                    press ENTER.
       
        axutil list

src :-https://technet.microsoft.com/EN-US/library/hh433542.aspx


-------------------------------------------------------------------------------------------

AxUtil and Windows PowerShell Commands for 

Deploying Models in AX 2012


Two command line tools are available for deploying and managing models and the model store:
  • Windows PowerShell, a command-line scripting tool
  • AXUtil, a command-line utility

Access Windows PowerShell

  1. On the Start menu, point to All Programs, point to Administrative Tools, and then click Microsoft Dynamics AX Management Shell.
  2. At the Windows PowerShell command prompt, PS C:\>, enter the Get-Help command, and then press ENTER. 
                  Get-Help AXModel (The command in this example returns a list of all model-related cmdlets.)

         Get-Help Export-AXModel -Full (The code in this example retrieves help for the Export-AXModel cmdlet.)

Export an .axmodel file (Windows PowerShell)

  1. On the Start menu, point to All Programs, point to Administrative Tools, and then click Microsoft Dynamics AX Management Shell.
  2. At the Windows PowerShell command prompt, PS C:\>, type the following command, and then press ENTER.
           Export-AXModel –Model <name> -File <Filename.axmodel>

This example exports the specified model to a file that has the specified file name.
You can use the –Server–Config, or –Database parameters to specify the environment to export from.

Import an .axmodel file (Windows PowerShell)

  1. On the Start menu, point to All Programs, point to Administrative Tools, and then click Microsoft Dynamics AX Management Shell.
  2. At the Windows PowerShell command prompt, PS C:\>, type the following command, and then press ENTER.
           Install-AXModel -File <Filename.axmodel> -Details

           This command installs the specified file in the same layer that it was exported from.
You can use the –Server–Config, or –Database parameters to specify the environment to import to.


AxUtil

After you install Microsoft Dynamics AX, the applicable AXUtil commands are available from the directory for Microsoft Dynamics AX Management Utilities.
To view the Help for AXUtil, enter the command AXUtil /?.

Access AXUtil

  1. On the Start menu, click Command prompt.
  2. Navigate to the directory for the management utilities. Typically, the location of this directory is %ProgramFiles%\Microsoft Dynamics AX\60\ManagementUtilities.
  3. At the command prompt, type the following command, and then press ENTER.
             axutil /? (This command displays the Help for AXUtil.)

Export an .axmodel file (AXUtil)

  1. On the Start menu, click Command prompt.
  2. Navigate to the directory for the management utilities. Typically, the location of this directory is %ProgramFiles%\Microsoft Dynamics AX\60\ManagementUtilities.
  3. At the command prompt, type the following command, and then press ENTER.
          axutil export /model:<modelname> /file:<filename> /verbose

This example exports the specified model to a file that has the specified file name.

Import an .axmodel file (AXUtil)

  1. On the Start menu, click Command prompt.
  2. Navigate to the directory for the management utilities. Typically, the location of this directory is %ProgramFiles%\Microsoft Dynamics AX\60\ManagementUtilities.
  3. At the command prompt, type the following command, and then press ENTER.
           axutil import /file:<filename> /verbose

This command installs the specified file in the same layer that it was exported from.
If the installation fails because of a conflict, we recommend that you rerun the command, and use the /conflict:push option to push the element that has the conflict to the related update layer. You can then resolve the conflict. For more information, see How to: Resolve Conflicts After Importing a Model.

src:- https://technet.microsoft.com/EN-US/library/hh352314.aspx
src:- https://technet.microsoft.com/EN-US/library/hh456294.aspx




Wednesday, September 23, 2015

Model, Model Stores and Base Line Data base in ax 2012:



Database :- 

AX Databases include

  • The Microsoft Dynamics AX database, 
  • The Model Store, and
  • The Baseline database. 


The AOS connects to the Microsoft Dynamics AX database to process transactions.
The AOS connects to the Model store to display application elements such as forms and reports.

Baseline Database:- The baseline database contains a model store that is used to upgrade X++ code to Microsoft Dynamics AX 2012. The baseline database is used to analyze application updates before they are applied.


Models:
A model is a set of elements in a given layer. Each layer consists of one or more models. Each layer contains one system-generated model that is specific to that layer. Every element in a layer belongs to only one model. In other words, no element can belong to two models in the same layer, and every element must belong to a model.

A model is permanently associated with the layer that is created in. If you need to move one of your models from one layer to another, you must create a project from the model in the AOT, export the project as an xpo file, create a target model in the desired layer, delete the original model to avoid having to resolve layer conflicts, and import the xpo file to the target model. If you are moving elements between models in the same layer, you can use the Move to model command in the AOT.

Models are stored in Model Store.

Model Store :-
The model store is the database where all application elements for Microsoft Dynamics AX are stored. Customizations are also stored in the model store. The model store replaces the Application Object Data (AOD) files that were used in earlier versions of Microsoft Dynamics AX.

Models that have been installed in the model store are used at run time.

Note: Models can be exported to files that have the .axmodel extension. These files are called model files. Model files are deployment artifacts. Model files can be signed with strong name signing and Microsoft Authenticode signing.

*Important :-
In Microsoft Dynamics AX 2012 R2, the model store was moved into a database that is separate from the business database. The name of the model store consists of the name of the business database plus _model.

Layer information and model information are integral parts of the model store. The Application Object Server (AOS) has access to the model store. The AOS manages layer flattening or overshadowing at runtime. That is, when you make an object modification in one layer, the modification overshadows the object on a lower layer at runtime. You could, for example, decide to change a caption on a standard form. The change is saved on your layer only, and the revised—or flattened—form replaces the standard form at runtime. The AOS also provides all the Microsoft Dynamics AX subsystems with model data, such as form rendering, report rendering, and X++ code.
Microsoft Dynamics AX contains sixteen layers. Each layer consists of one or more logical parts called models. A model is generated for each layer. For example, VAR Model is the model that the system generates for the VAR layer. The system-generated models let you install and work with the base Microsoft Dynamics AX system. When you customize the Microsoft Dynamics AX program, you can take advantage of the capabilities of models.

The model store is used in the following ways in Microsoft Dynamics AX:

Installation – During installation, the Setup program uses axutillib.dll to import the .axmodel files from the installation path into the model store.

Upgrade – During an upgrade, the application files, or AOD files, from the earlier version are imported into the model store, which is the new model. The application files are also imported into the baseline model store, or the model store for the earlier version of the metadata. The baseline model store is similar to the old folder in earlier versions of Microsoft Dynamics AX.

Development environment – In the development environment, developers can continue to use .xpo files to export and import code. Use .axmodel files to migrate application elements from one environment to another, such as from a development environment to a test environment. Export models from the source system to .axmodel files, and then import .axmodel files into the target system.

Run time – At run time, an Application Object Server (AOS) instance retrieves the application elements, such as forms, reports, and classes, from the model store to respond to client requests.

The following diagram provides an overview of the model store architecture.




https://technet.microsoft.com/en-us/library/gg732276.aspx
https://technet.microsoft.com/en-us/library/dd362019.aspx

Thursday, September 10, 2015

List of important tables for Role Based Security in AX 2009 and AX 2012




AX 2009 Tables :-

UserGroupList :-
The UserGroupList table contains the list of users associated with each user groups in Ax.

UserGroupInfo:- The UserGroupInfo table contains the list of available user groups in Ax.

UserInfo           :-The UserInfo table contains the list of users in Ax and their Active Directory information and default company information.

AccessRightsList Table :- Group rights

UtilIdElements :- The UtilIdElements table contains the application model shown in the AOT.

UtilElements :- The UtilElements table contains the application model shown in the AOT.

AX 2012 Tables :-

SecurityRole
           :-The SecurityRole table reflects the list of roles defined by the security AOT role node.

SecurityUserRole    :-The SecurityUserRole table contains the user to role mappings.

SecurityTask           :-The SecurityTask table contains the list of duties and privileges that have been defined by the AOT security duty and security privilege nodes.

SecuritySubTask    :- The SecuritySubTask table contains the duty to privilege mappings that have been specified on the security duty AOT nodes.

SecurityRoleTaskGrant  :-The SecurityRoleTaskGrant table contains the list of role to duty mappings and role to privilege mappings as defined by the AOT security role node.

SecurityTaskEntryPoint :- The SecurityTaskEntryPoint table contains the list of privilege to entry point mappings that have been specified on the AOT security privilege node.

OMUserRoleOrganization :-The OMUserRoleOrganization table maintains the mapping between user roles and organizations.

OMInternalOrganization  :-The OMInternalOrganization table is the base table for each of the organizations.

How to fetch the UserGroup and Permissions Using X++ in AX 2009



static void Esh_UserGroup(Args _args)
{

 AccessRightsList accessRightsList;
 UserGroupList  userGroupList;
 UserGroupInfo userGroupInfo;
 UtilIdElements utilIdElements;
 ;

 while select UserGroupList
 join UserGroupInfo
 where UserGroupInfo.Id == UserGroupList.groupId
 join AccessRightsList
 where AccessRightsList.groupId == userGroupInfo.id

 {
  select * from utilIdElements;
  {
  info(strFmt("%1,%2,%3,%4", userGroupList.userId,userGroupList.groupId,accessRightsList.accessType, accessRightsList.elementName));
  }
 }


}

====================================================================


static void Esh_MenuItems(Args _args)
{
 AccessRightsList accessRightsList;
 UserGroupList  userGroupList;
 UserGroupInfo userGroupInfo;
 UtilIdElements utilIdElements;
 ;

while select UserGroupList
 join UserGroupInfo
 where UserGroupInfo.Id == UserGroupList.groupId
 join AccessRightsList
 where AccessRightsList.groupId == userGroupInfo.id
{
select * from utilIdElements;
 {
 Info(strFmt("%1,%2",userGroupInfo.id,accessRightsList.elementName));
  }
}
}

Thursday, September 3, 2015

How to fetch the list of table related to each module with the help of security key using X++

static void Esh_FindTablesFromSecKey(Args _args)
{
    // The name of the Security key to be specified here
    str                     secKeyName      = "smmCRM";
    Dictionary              dictionary      = new Dictionary();
    SecurityKeyId           secKeyId        = dictionary.securityKeyName2Id(secKeyName);
    TableId                 tableId;
    DictSecurityKey         dictSecurityKey;
    DictTable               dictTable;
    container               keyIds;
    int                     i;
    ;

    if (secKeyId)
    {
        // Find all children of the specified Security key
        for (i = dictionary.securityKeyNext(0); i; i = dictionary.securityKeyNext(i))
        {
            dictSecurityKey      = new DictSecurityKey(i);          

            while (dictSecurityKey.parentSecurityKeyId())
                dictSecurityKey = new DictSecurityKey(dictSecurityKey.parentSecurityKeyId());

            if (dictSecurityKey.id() == secKeyId)
                keyIds += i;
        }

        // Find all tables that have an appropriate Security key
        i = 0;
        for (tableId = dictionary.tableNext(0);tableId;tableId = dictionary.tableNext(tableId))
        {
            dictTable = new DictTable(tableId);
            if (!dictTable.isMap() && !dictTable.isTmp() && !dictTable.isView())
            {
                if (confind(keyIds, dictTable.securityKeyId()))
                {
                    i++;
                    info(dictTable.name());
                }
            }
        }
    }

    info(strfmt("%1 tables have Security key '%2'", i, secKeyName));
}

Wednesday, September 2, 2015

How to fetch the list of tables of each module with the help of configuration key using X++

static void FindTablesFromConfigKey(Args _args)
{
    // The name of the configuration key to be specified here
    str                     configKeyName   = "Bank";
    Dictionary              dictionary      = new Dictionary();
    ConfigurationKeyId      configKeyId     = dictionary.configurationKeyName2Id(configKeyName);
    TableId                 tableId;
    DictConfigurationKey    dictConfigurationKey;
    DictTable               dictTable;
    container               keyIds;
    int                     i;
    ;

    if (configKeyId)
    {
        // Find all children of the specified configuration key
        for (i = dictionary.configurationKeyNext(0); i; i = dictionary.configurationKeyNext(i))
        {
            dictConfigurationKey = new DictConfigurationKey(i);

            while (dictConfigurationKey.parentConfigurationKeyId())
                dictConfigurationKey = new DictConfigurationKey(dictConfigurationKey.parentConfigurationKeyId());

            if (dictConfigurationKey.id() == configKeyId)
                keyIds += i;
        }

        // Find all tables that have an appropriate configuration key
        i = 0;
        for (tableId = dictionary.tableNext(0);tableId;tableId = dictionary.tableNext(tableId))
        {
            dictTable = new DictTable(tableId);
            if (!dictTable.isMap() && !dictTable.isTmp() && !dictTable.isView())
            {
                if (confind(keyIds, dictTable.configurationKeyId()))
                {
                    i++;
                    info(dictTable.name());
                }
            }
        }
    }

    info(strfmt("%1 tables have configuration key '%2'", i, configKeyName));
}

How to enable the dimension fields based on the Item selected on the form.

[Form] public class KMTShipFromWarehouses extends FormRun {     InventDimCtrl_Frm_EditDimensions        inventDimFormSetup;     /// &l...