Friday, February 22, 2013

Disable "Changing company accounts to: " infolog warning

If you are using multiple companies in Dynamics AX you likely have seen the "Changing company accounts to: <company>" infolog warning when changing between companies. This is particularly annoying when working with intercompany sales orders and purchase orders when your business process has you switching back and forth between companies. This is pretty easy to disable with a simple modification to the Application.setDefaultCompany() method.





In the Application.setDefaultCompany() method set the warning flag to 0 instead of hexidecimal 0x08 to disable the warning message. You could also further customize this to read the setting per user or from some other location if you wanted.

See my post about adding a color bar per company to further enhance the multi-company experience.

Note: The code below is from Dynamics AX 2009 but the same change can be made in Dynamics AX 2012.

boolean setDefaultCompany(selectableDataArea _selectableDataArea, boolean dialog = true)
{
    selectableDataArea thisCompany = curext();
    UserInfo userInfo;
    boolean ret;
    Currency currency;
    SysGlobalCache cache = appl.globalCache();

    ret = super(_selectableDataArea);
    if (infolog && infolog.docu())
    {
        infolog.docu().updateFromParameters();
    }

    if (infolog)
    {
        infolog.nationalCurrencyPrefix('');
        infolog.nationalCurrencyPostfix('');
        infolog.nationalCurrencyFactor(1);

        currency = Currency::find(CompanyInfo::find().CurrencyCode);
        if (currency)
        {
            infolog.isoCurrencyCode(CompanyInfo::find().CurrencyCode);
        }
        else
        {
            infolog.isoCurrencyCode('');
        }
    }


    //Set the warn flag to 0 to disable the
    // "Changing company accounts to: <company>" infolog warning
    //#define.WarnFlag(0x08)
    #define.WarnFlag(0x00)


    if (dialog && new Session().clientKind() != ClientType::COMObject)
    {
        if (thisCompany != _selectableDataArea)
        {
            if (!cache.get(classstr(Info), identifierstr(Autologoff), false))
            {
                select userInfo
                    where userInfo.Id == curuserid();

                if (userInfo && userInfo.GeneralInfo & #warnFlag)
                    warning(strfmt("@SYS53441", _selectableDataArea));
            }
        }
    }

    InventDim::findOrCreateBlank();
    return ret;
}

No comments:

Post a Comment