At this point I’m 99% sure almost all of us have been asked the “can we change the theme color to the one of our company/brand?” question. While this is unfortunately not possible what we can do is defining a different theme for each company.
This is just a proof of concept. I still haven’t managed to successfully change the theme when the DataArea is changed using the company list.
The standard
By default each user sets his desired theme in the user settings:
If you check the SysUserInfo table you’ll find the enum Theme field, its type is SysUserInfoTheme. This enum is not extensible and this is one of the reasons we cannot add new colors (the other is the class which handles the themes being not accessible).
The customer might ask us to set a fixed different color/theme for different companies. To be sure that the users don’t misidentify different companies or even environments.
Let’s do it
For this example I’ve decided to add an override on the Legal Entities form and set the new theme to be used there.
Add a new SysUserInfoTheme enum field to the CompanyInfo table:
Then add the field to the OMLegalEntity form:
We now have a list of the available themes. Let’s add the functionality.
If we do a metadata search of the SysUserInfo Theme field we’ll find it’s being used by the SysFormUtil class in the GetThemeDensityForCurrentUser. We’ll extend this method in the following way:
By returning our field’s value we make the system select the value from the CompanyInfo table instead of the one defined by the user. For example:
USMF
THMF
SAMF
Different companies, different themes!
Now I only need to find a way to make this work when changing companies. I’ve tried with the lookup form which shows the available companies with no luck. Any ideas?
5 Comments
really a massive blogs , it is interesting.
Hello Adrià,
Have you managed to change the theme when the DataArea is changed using the company list?
I didn’t investigate further on this, but check the SysCompanyChooser form. You should be able to extend the modified method of the dataArea control and force the change there.
Hi Maxim, Adrià is correct. You can set a post handler on the DataArea_id control on SysCompanyChooser. I found an example with screenshots on step 3.2 here: https://emiralfg.com/en/colours-per-company-in-dynamics-365-for-operations/