Wednesday 11 November 2020

split default dimensions in ax 2012

 

split default dimensions in ax 2012


static void splitDimAndExport(Args _args)

{

    DimensionAttributeValueSetStorage   dimStorage;

    DimensionValue                    bu,costCenter,cust,custbu,custsow,dept,fa,fda,ir,inv,proj,purpose,rda,vend,worker;

    Counter                             i;

    ProjTable                           projTable;

     

    

    // DimensionDefault is a RecId that combines all Dimension Values

    while select projTable where projTable.ProjId == '201P000134-01'

    {

        dimStorage = DimensionAttributeValueSetStorage::find(projTable.DefaultDimension);  

 

   

        for (i= 1 ; i<= dimStorage.elements() ; i++)

        {

            

            // Change the string "CostCenter" to whatever financial dimension you want

            if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "BusinessUnit")

            {

                bu = '';

                bu = dimStorage.getDisplayValueByIndex(i);

            }

            if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "CostCenter")

            {

                costCenter = '';

                costCenter = dimStorage.getDisplayValueByIndex(i);

            }

            if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Customer")

            {

                cust = '';

                cust = dimStorage.getDisplayValueByIndex(i);

            }

            if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Customer_BU")

            {

                custbu = '';

                custbu = dimStorage.getDisplayValueByIndex(i);

            }

            if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Customer_SOW")

            {

                custsow = '';

                custsow = dimStorage.getDisplayValueByIndex(i);

            }

            if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Department")

            {

                dept = '';

            

                dept = dimStorage.getDisplayValueByIndex(i);

            }

            if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "FixedAsset")

            {

                fa = '';

            

                fa = dimStorage.getDisplayValueByIndex(i);

            }

            if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "FixedDepositAccount")

            {

                fda = '';

                fda = dimStorage.getDisplayValueByIndex(i);

            }

            if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "InterestReceivable")

            {

                ir = '';

            

                ir = dimStorage.getDisplayValueByIndex(i);

            }

            if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Investors")

            {

                inv = '';

            

                inv = dimStorage.getDisplayValueByIndex(i);

            }

            if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Project")

            {

                proj = '';

            

                proj = dimStorage.getDisplayValueByIndex(i);

            }

            if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Purpose")

            {

                purpose = '';

            

                purpose = dimStorage.getDisplayValueByIndex(i);

            }

            if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "RecurringDepositaccount")

            {

                rda = '';

            

                rda = dimStorage.getDisplayValueByIndex(i);

            }

            if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Vendor")

            {

                vend = '';

            

                vend = dimStorage.getDisplayValueByIndex(i);

            }

            if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Worker")

            {

                worker = '';

                worker = dimStorage.getDisplayValueByIndex(i);

            }

            

        }

        info(strFmt("%1 , %2 , %3 , %4 , %5 , %6 , %7 , %8 , %9 , %10 , %11 , %12, %13, %14 , %15 ",bu,costCenter,cust,custbu,custsow,dept,fa,fda,ir,inv,proj,purpose,rda,vend,worker));

    }


}

Monday 9 November 2020

get User roles using x++


User roles

static void userRoles(Args _args)

{

     UserInfo            userInfo;

    SecurityUserRole    securityUserRole;

    SecurityRole        securityRole;

    str                 st;

       

    ;

        st = ',';

    while

    select userInfo

        join    securityUserRole

        where   securityUserRole.User == userInfo.Id

    {               

          

       

        securityRole = null;

        select securityRole

        where  securityRole.RecId == securityUserRole.SecurityRole;

       

        if (securityRole)

        {

            //info(securityRole.AotName);

            //info(securityRole.Name);   

            info(strFmt("%1 , %2 , %3",userInfo.Id,securityRole.Name,securityRole.Description)); //info(securityRole.Description);                      

        }  

    }