Tuesday, May 12, 2020

Get Model list with versions & Application & Platform Version X++ D365FO

class GetModelListCls
{
    /// <summary>
    /// Runs the class with the specified arguments.
    /// </summary>
    /// <param name = "_args">The specified arguments.</param>
    public static void main(Args _args)
    {
        str60                   moduleName;
        CLRObject               moduleModels, sanModels;
        CLRObject               modelEnumerator, sanEnumerator;
        str60                   moduleVersion;

        Microsoft.Dynamics.AX.Metadata.MetaModel.ModelInfo modelInfo;

        moduleModels = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetInstalledModuleNames();
        modelEnumerator = moduleModels.GetEnumerator();
        
        while (modelEnumerator.moveNext())
        {
            moduleName = modelEnumerator.get_Current();
            sanModels = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetModelsInModuleSortedByDisplayName(moduleName);
            sanEnumerator = sanModels.GetEnumerator();
            sanEnumerator.MoveNext();
            modelInfo = sanEnumerator.get_Current();

            moduleVersion = strfmt("%1.%2.%3.%4",
                                        modelInfo.VersionMajor,
                                        modelInfo.VersionMinor,
                                        modelInfo.VersionBuild,
                                        modelInfo.VersionRevision);
            // modelInfo.Layer // Filter based on layers - ISV layer 8
            info(strFmt("%1 - %2 - %3",modelInfo.Module, moduleVersion,modelInfo.Publisher));
        }

        Microsoft.Dynamics.BusinessPlatform.ProductInformation.Provider.ProductInfoProvider provider = Microsoft.Dynamics.BusinessPlatform.ProductInformation.Provider.ProductInfoProvider::get_Provider();
        info(strFmt("Application version: %1",provider.ApplicationVersion));
        info(strFmt("Platform version: %1  ( %2 )",provider.ApplicationVersion,provider.get_PlatformBuildVersion()));
    }

}

No comments:

Post a Comment

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...