fbpx
  • Another way of doing consulting.

Start » Colors by company in Dynamics 365 For Operations

Colors by company in Dynamics 365 For Operations

How to get it?

In this new version, the color schemes that the user sees are grouped so D365FO call Topics.
This means that we cannot choose a specific color, but we can choose a certain combination of colors among several
predefined by the system. The standard application gives the user the possibility to choose one of these themes, which are
apply to any company in which the user is working (Options > User options):

A very common request in implementations of Dynamics is that these colors are changed automatically
depending on the company in which the user is working. This feature is very useful when
works with several environments (test, production...) and with several companies, since the user can, in a way
immediately, place yourself "visually" in the environment or company in which you are, decreasing the possibility
of mistakes
.

The good news is that it is easy to implement. We will need to perform three steps:

  1. Persistent storage that will determine which themes to use for a given company.
    We can extend some existing parameterization table (the CompanyInfo table is a good candidate).
    In any case, it will obviously be necessary to implement some kind of user interface for it to be
    can change. In this case, we have chosen a new parameterization table, with an additional field of type NoYes that
    allows you to activate or deactivate it (UseCompanyTheme):

    Along with its corresponding user interface in the form of legal entities (OMLegalEntity):

    The theme to apply is one of the possible values of the SysUserInfoTheme enumerator. According to our
    needs, we can complicate it more or less (pack it in a container, for example), but the option
    The easiest way is to create a field to store (and use) it directly:

  2. The actual code that changes the theme to the user. For this, we use the functionality of Chain Of Command
    over the GetThemeDensityForCurrentUser() method of the SysFormUtil class. In this case, we have opted for
    centralize the functionality in a static method of the parameter table, and give precedence to the
    colors by company: If they are not applicable, we follow the preferences of the user. The important line
    the one that does the “magic”, is the call to appl.setTheme():

  3. The entry points, which will call the method where we have centralized the functionality (in our case,
    static in the new parameter table). We will need to put two:

    1. Implement a subscriber to the Application class's onSetDefaultCompany delegate:

    2. Implement a subscriber to the post-modified method of the DataArea_id control of the SysCompanyChooser system form:

We can say that this last entry point is the moment of the fireworks (since it is
immediately visible to the user), of this functionality. This system form is the one that is normally
used to switch companies in the browser in any form. The visual effect of this last change is
that, immediately after the user has chosen the new company, the screen will be refreshed with the
topic applicable to the new company.

Result

Parameterization

Application of the functionality

As mentioned above, in this example, we have chosen to centralize the functionality (entry points
and Theme application) in the parameters table, and prioritize colors by company:

But as long as the premises stated above are met, it should work.
Enjoy it 😉

JM stew

We talk about...

Related Posts

tags

Latest related posts