Skip to main content
Post a question

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id : //Vme5NfIzr4omgtZs1v9s

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

Vishal Tiwari Profile Picture Vishal Tiwari 393













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

}


  
  




This was originally posted here.

Comments

*This post is locked for comments