model

Default AX model for all users

If you want to set the default AX model for all of your active user accounts on a certain layer, you may run the following job to do so.

Whenever a new developer joins in, you may include running this job in your account creation process to make sure they do not try to check in code to the wrong place, but only to your correct default AX model.

Do not forget to change the layer and the name of the model.

static void WIK_UpdateDefaultModel(Args _args)
{
    UserInfo                userInfo;
    UserInfoStartupModel    userInfoStartupModel;
    UserInfoStartupModel    userInfoStartupModelDB;
    UtilEntryLevel          layer = UtilEntryLevel::cus;
    ModelId                 modelId = any2int((select firstOnly Model from SysModelManifest where SysModelManifest.Name == 'MyModel').Model);

    ttsBegin;

    while select userInfo
        where userInfo.accountType  == UserAccountType::ADUser
        notexists join userInfoStartupModel
            where  userInfoStartupModel.UserId  == userInfo.id
                && userInfoStartupModel.Layer   == layer
                && userInfoStartupModel.ModelId == modelId
    {
        userInfoStartupModelDB.clear();
        userInfoStartupModelDB.initValue();
        userInfoStartupModelDB.Layer            = layer;
        userInfoStartupModelDB.UserId           = userInfo.id;
        userInfoStartupModelDB.ModelId          = modelId;
        
        try
        {
            if (userInfoStartupModelDB.validateWrite())
            {
                userInfoStartupModelDB.insert();
            }
            else
            {
                throw error('We have a problem');
            }
        }
        catch
        {
            exceptionTextFallThrough();
        }
    }

    update_recordset userInfoStartupModel
        setting ModelId = modelId
        where userInfoStartupModel.Layer    == layer;

    ttsCommit;
}

MSDN link for UserInfoStartupModel: https://msdn.microsoft.com/en-us/library/userinfostartupmodel.aspx

By |2015-12-22T14:47:21+01:00December 22nd, 2015|Categories: AX 2012|Tags: , , , , |1 Comment

PowerShell and AXModel files

In AX 2012 there is a very high chance that you have to work with the new AXModel files.

You may receive an ISV solution, or a Microsoft hotfix and you would like to know what is inside. If you have installed the management extensions, you can go to Start menu > Administrative tools > Microsoft Dynamics AX 2012 Management Shell to open PowerShell to access the AX-specific utilities.

We have a hotfix in our example, and would like to see what objects are inside, which may cause a conflict with out customizations. You can run the following command to get more details from our AXModel hotfix:

(more…)

By |2015-11-23T17:53:12+01:00October 9th, 2012|Categories: AX 2012|Tags: , , , , |0 Comments
Go to Top