Enter the key words to find the related topics

AX application user login authentication

Requirement: AX application need to open with user credential. If credential is given wrong then application should close.

Solution: Modified startupPost method in  Info class as shown below.



    Dialog                dialog;
    Dialogfield         dName,dPassword;
    Userinfo              user;
    boolean                ret;
    SysClientSessions   sysClientSessions;
    AxaptaUserManager   axUserManager;

    dialog      = new dialog("User login");
    dialog.formBuildDesign().height(170);
    dialog.formBuildDesign().width(400);

    dName       = dialog.addField(ExtendedTypestr(userid),"User name");
    dPassword   = dialog.addField(ExtendedTypestr(Password),"Password");
    dName.enabled(false);

    dName.value(curuserid());

     select firstOnly id from user
            where user.id == dName.value();

    if (user.id != "Admin")
    {
        dPassword.passwordStyle(true);
        dialog.parmIsModal(true);


        axUserManager = new AxaptaUserManager();
        if (dialog.run())
        {
            if (!axUserManager.validatePassword(user.networkAlias , user.NetworkDomain, dPassword.value()))
            {
                infolog.shutDown(true);
            }
            else
            {
                Box::info("Access granted.","AX Group","ERP");
                ret = true;
            }
        }

        if (ret == false && user.RecId)
        {
            infolog.shutDown(true);
        }
    }

X++ code to update Dimensions for the Item,Customer and Vendor

static void ItemDimUpdate(Args _args)
{
    InventTable inventTable;
    Struct dim = new Struct();
    container dimValue;
    DimensionDefault DimensionDefault;
    ; 

    dim.add('BusinessUnit', '002');
    dim.add('CostCenter', '007');
    dim.add('Department', '022');
    dim.add('ItemGroup', 'Audio Test');
    dim.add('Project', '000002'); 

    dimValue += dim.fields();
    dimValue += dim.fieldName(1);
    dimValue += dim.valueIndex(1);
    dimValue += dim.fieldName(2);
    dimValue += dim.valueIndex(2);
    dimValue += dim.fieldName(3);
    dimValue += dim.valueIndex(3);
    dimValue += dim.fieldName(4);
    dimValue += dim.valueIndex(4);
    dimValue += dim.fieldName(5);
    dimValue += dim.valueIndex(5); 

    ttsBegin; 

    DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(dimValue);
    inventTable = inventTable::find("A0001",true);
    inventTable.DefaultDimension = DimensionDefault;
    inventTable.update(); 

    ttsCommit; 

}

Disable financial dimensions through X++ code in AX 2012




Disabling particular financial dimension based on record or on particular form quite tricky in AX 2012.
Here is an example to achieve disabling Business unit financial dimension on Customers form in AX 2012.
Process to disable Business Unit financial dimension on Customers form.
1. Create a new parm method in ‘DimensionDefaultingControllerBase’ class as shown below
1
2
3
4
void parmEditableDimensionAttributeSetId(RefRecId _editableDimensionAttributeSetId  = editableDimensionAttributeSetId)
{
    editableDimensionAttributeSetId = _editableDimensionAttributeSetId;
}
2. Create a new method in ‘CustTable’ form as shown below
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
private void setDimensionAttributeSetStorage()
{
    DimensionAttribute              dimAttr;
    DimensionAttributeSetItem       dimAttrSetItem;
    DimensionEnumeration            dimensionSetId =  DimensionCache::getDimensionAttributeSetForLedger();
    DimensionAttributeSetStorage    dimensionAttributeSetStorage;
    ;
    dimensionAttributeSetStorage = new DimensionAttributeSetStorage();
    while select * from dimAttr
            order by Name
            where dimAttr.Type != DimensionAttributeType::MainAccount
        join RecId from dimAttrSetItem
            where dimAttrSetItem.DimensionAttribute == dimAttr.RecId &&
                dimAttrSetItem.DimensionAttributeSet == dimensionSetId
    {
        if (dimAttr.Name != 'BusinessUnit') // Except BusinessUnit rest should enable
            dimensionAttributeSetStorage.addItem(dimAttr.RecId, dimAttr.HashKey,NoYes::Yes);
    }
      dimensionDefaultingController.parmEditableDimensionAttributeSetId(dimensionAttributeSetStorage.save());
}
3. Add below highlighted code in ‘init’ method of ‘CustTable’ form as shown below
Calling newly created method before dimensionDefaultingController.pageActivated();
1
2
3
4
5
6
dimensionDefaultingController = DimensionDefaultingController::constructInTabWithValues(true, true, true, 0, this, tabFinancialDimensions, "@SYS138487");
    dimensionDefaultingController.parmAttributeValueSetDataSource(custTable_ds, fieldStr(CustTable, DefaultDimension));
    // Added by Manikanta on 22/05/2019 DisableFinDimensions - Begin
    this.setDimensionAttributeSetStorage();
    // Added by Manikanta on 22/05/2019 DisableFinDimensions - End
    dimensionDefaultingController.pageActivated();
4. Now open Customers form & check financial dimensions tab it shows as below.
Can see Business Unit financial dimension disabled, highlighted one.
download