Thursday, May 16, 2013

How to copy Dynamics AX 2009 license from one AX instance to another

The following job can be used to copy Dynamics AX license information from one instance to another, for instance from PROD environment to TEST or DEV.

The job is tested and proved on AX4.0 and AX 2009, but also must work with AX3.0. Before using job please see TODOs.

//Job exports Dynamics AX license information to a license file
static void ExportLicenseFile(Args _args)
{
    SysConfig   sysConfig;
    AsciiIO file = new AsciiIO("c:\\license.txt", "W"); //TODO: 1. Define file name
    ;
    file.read();
    file.write("LicenseVersion 2");
    file.write("");
    select sysConfig
    where sysConfig.configType == ConfigType::LicenseName;  //TODO: 2. Change value according to Dynamics AX vesrion: AX3.0 - ConfigType::LicensName, AX4.0 - ConfigType::LicensName, AX 2009 - ConfigType::LicenseName
    file.write(strFmt("License #%1", sysConfig.value));
    file.write(" Properties");
    select sysConfig
    where sysConfig.configType == ConfigType::SerialNo;
    file.write(strFmt("  Serial #%1", sysConfig.value));
    file.write(" EndProperties");
    file.write("");
    file.write(" Codes");
    file.write("");
    while select sysConfig
    order by id
    where sysConfig.configType == ConfigType::AccessCodes &&
          sysConfig.value != ""
    {
        file.write(strFmt("  CodeLine #%1", sysConfig.id + 1));
        file.write(strFmt("    Value #%1", sysConfig.value));
        file.write("  EndCodeLine");
        file.write("");
    }
    file.write(" EndCodes");
    file.write("");
    file.write("EndLicense");
    box::info("Done!");
}
See also the following approach to copy Dynamics AX license, I didn't checked it, so treat it as is:
http://learnax.blogspot.ru/2010/01/copying-license-in-dynamics-ax.html


No comments:

Post a Comment