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());
    }

}


 
 



5 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

Powered by Blogger.