Configuration Key Status Using X++ Code


As we are aware, Configuration key controls access to specific feature. To know about the status of a configuration key, the user has to traverse Administration->Setup->System-> Configuration.
Instead with the following job, a user can know the status of all the configuration keys that is being used in the system.

//Configuration key names and their enable state.
static void ConfigurationKey(Args _args)
{
    ConfigurationKeySet   configKeySet;
    DictConfigurationKey  dictConfigKey;
    Object                         formRun ;
    Map                             mapConfigKey;
    str                                strOutput;
    int                                i;
    ;

    mapConfigKey = new Map(Types::Integer, Types::String);
    configKeySet = new ConfigurationKeySet();
    configKeySet.loadSystemSetup();

    for (i=1; i <= configKeySet.cnt(); i++)
    {
        dictConfigKey = new DictConfigurationKey(configKeySet.cnt2Id(i));
        strOutput     = dictConfigKey.enabled() ? "enabled:" : "disabled:";
        strOutput    += " " + " " + dictConfigKey.name();
        mapConfigKey.insert(i, stroutput);
    }

    _args = new Args(formstr(SysPick));
    _args.parmObject(mapConfigKey);

    formRun = classfactory.formRunClass(_args);
    formRun.init();
    formRun.run();

    formRun.setCaption('ConfigurationKey Status');
    formRun.wait();
}
20851015.jpg
On executing this job, the output will be displayed in a SysPick form

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.