D365 F&O: Change Theme/Color Per Legal Entity/Company














Folks, I am going to discuss a beautiful feature out there in standard F&O – where you can change the Colour/Theme of the Forms/UI as per your choice. (Options (Top right gear icon) >> User options)




















Have you ever thought if you can change the Theme as per company/Legal entity? Yes, that too possible with few code/objects enhancement/tweaking under Forms/Tables/Classes.

I would provide you with very simple steps to incorporate that in your VS – X++ objects/Codes –
  • -        Colours/Theme applied is one of the values from SysUserInfoTheme Base Enum.
  • -        appl.setTheme is the crux – it will handle the application colour theme.
  • -        Subscribe to the onSetDefaultCompany delegate of Application class.
  • -        Update the Theme value to CompanyInfo new field:
  • -        Below code will help implement the functionality









-        


class VTOMLegalEntityEventHandlers
{
    [SubscribesTo(classStr(Application), delegateStr(Application, onSetDefaultCompany))]
    public static void Application_onSetDefaultCompany()
    {
        appl.setTheme(CompanyInfo::find().VTCompanyTheme);
    }

    [FormControlEventHandler(formControlStr(OMLegalEntity, CompanyThemeControl), FormControlEventType::SelectionChanged)]
    public static void CompanyThemeControl_OnSelectionChanged(FormControl sender, FormControlEventArgs e)
    {
        FormListBoxControl listBox = sender;
        FormRun fr = sender.formRun();
        FormDataSource companyInfo_ds = fr.dataSource(formDataSourceStr(OMLegalEntity, CompanyInfo));
       
        companyInfo_ds.write();
        appl.setTheme(listBox.selection());
    }

}


 
 



9 comments:

  1. it dont work if we change the dataarea from the address bar

    ReplyDelete
  2. This particular papers fabulous, and My spouse and i enjoy each of the perform that you have placed into this. I’m sure that you will be making a really useful place. I has been additionally pleased. Good perform! Rebranding

    ReplyDelete
  3. I am 1 year late, but does this solution still works ?
    I would like to do the exact same thing for my companie.
    I tried it, but the top row (where "Finance & Operations" is written and where the search bar is present) stays always in black. Is there a way to change it to the color chosen for the Legal Entity ? (exactly the same as in your screenshots)
    Thanks a lot for your help.
    Best regards.

    ReplyDelete
  4. Here more than 2 years later I would like to implement a variation of this, but like the previous comment the "Finance and Operations" part of the top line doesn't change. Any solution for that?

    ReplyDelete
  5. If you have the black bar in the upper section is probably because you have enabled the legacy navigation bar that shows you the route of where you are in the ERP. if you want to see the color again you'll have to disable it here: System Admin--Setup-client performance options-disable legacy navigation bar button

    ReplyDelete
  6. Unfortunately, when refreshing the browser window, the color reverts to the default. Is there any solution for this?

    ReplyDelete
  7. This only seems to works from the Legal Entities Form, If you change companies from the main address bar as 99% of users will, or login with a default company set it will not change colour and worse it stays the the same colour if switching from a company that has this turned on.

    ReplyDelete
  8. Just tested this in application release 10.0.37. Indeed, methods Application.setDefaultCompany/OnSetDefaultCompany are not beeing triggered after startup nor when manually changing legal entity using right upper corner textbox field. However, if business logic using appl.setTheme is placed in a class method with attribute [SubscribesTo(classStr(ApplicationStartupEventManager), staticDelegateStr(ApplicationStartupEventManager, onInteractiveSessionCreated))] then it will do the trick.

    ReplyDelete

Powered by Blogger.