Pages

Banner 468 x 60px

 

Monday, April 16, 2018

X++ code for check license Microsoft Dynamics AX 2012 R3

0 comments
Hi Everybody,

I want to share X++ code  for check license Microsoft Dynamics AX 2012 R3 :

static void ABUCheckLisense(Args _args)
{

    SysSecRoleEntryPointsTmp    srepTbl;
    SysUserLicenseMetadataTmp   slsaTmp;
    SecurityRole                securityRole;
    CommaTextIo                 commaTextIo;
    FileIOPermission            permission;
    MenuFunction                menuFunction;
    str                         menuLabel;
    str                         fileName = @"C:\Temp\TEST.csv";
    //str                         fileName = "C:\Temp\.csv";
    FromTime                    startTime = timeNow();
    #File

    //delete_from srepTbl;
    //delete_from slsaTmp;

    SysUserLicenseMiner::BuildLicenseMetadataTable(slsaTmp);
    SysUserLicenseMiner::BuildRoleToUserTypeInfo(slsaTmp, srepTbl);

    permission = new FileIOPermission(fileName,#io_write);
    permission.assert();
    commaTextIo = new CommaTextIo(fileName,#io_write);

    //Header
    commaTextIo.write(
        "Entry type",
        "Entry point AOT name",
        "Entry point label",
        "Role AOT name",
        "Role name",
        "License type");

    while select srepTbl
    /*    join securityRole
        where srepTbl.RoleRecId == 1085499//srepTbl.RoleRecId
        && securityRole.RecId == srepTbl.RoleRecId*/
    {
        menuFunction    = null;
        menuLabel       = '';
        switch (srepTbl.EntryPointType)
        {
            case EntryPointType::MenuItemAction:
                menuFunction = new MenuFunction(srepTbl.EntryPointName, MenuItemType::Action);
                break;

            case EntryPointType::MenuItemDisplay:
                menuFunction = new MenuFunction(srepTbl.EntryPointName, MenuItemType::Display);
                break;

            case EntryPointType::MenuItemOutput:
                menuFunction = new MenuFunction(srepTbl.EntryPointName, MenuItemType::Output);
                break;
        }

        if (menuFunction)
        {
            menuLabel = menuFunction.label();
        }

        commaTextIo.write(
            strFmt("%1",srepTbl.EntryPointType),
            srepTbl.EntryPointName,
            menuLabel,
            srepTbl.RoleAotName,
            SysLabel::labelId2String(securityRole.Name),
            strFmt("%1",srepTbl.UserLicType)
            );
    }
    CodeAccessPermission::revertAssert();

    info(strFmt("Total time: %1", timeConsumed(startTime, timeNow())));

}

0 comments:

A financial dimension value is based on the LAND-00013 record and has been used on a transaction. You cannot delete the LAND-00013 record AX 2012

 A financial dimension value is based on the LAND-00013 record and has been used on a  transaction. You cannot delete the LAND-00013 record ...