How To Get Color Change Option Into Legal Entity

User don’t have the option to change the color theme for individual legal entity.


High Resolution Steps

Get color changing option to Legal entity same like user options -> preferences 

Create a base enum

Extend the CompanyInfo (Standard table)

Extend the OMLegalEntiy(Standard form)


Detailed Resolution Steps

Step 1

Create new enum field named “COLOCompanyTheme” in the “CompanyInfo” standard table. In properties set the enum type as “SysUserInfoTheme”.


Step 2  

Extend the “OMLegalEntiy” Standard form. Create a tab page named “CompanyTheme” in tab section and set the pattern as “Custom”.


Step 3

Create a list box named “CompanyThemeControl” under the CompanyTheme Tab page. 

Set the list box properties:

1. set Extended Style: sysUserSetup_theme 

2.  Auto Declarartion : Yes 

3. Data Source: CompanyInfo 

4.  Data Field: COLOCompanyTheme (Give the base enum field name that you have created).


Step 4  

Create a class named “COLOOMLegalEntity”.


Step 5

The below code has been written by making use of event handlers and it helps us to change the color of current legal entity. 


    class COLOOMLegalEntity

{

[SubscribesTo(classStr(Application), delegateStr(Application, onSetDefaultCompany))]

public static void Application_onSetDefaultCompany()

{

appl.setTheme(CompanyInfo::find().COLOCompanyTheme);

}

[FormControlEventHandler(formControlStr(OMLegalEntity, CompanyThemeCantrol), 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());

}

}
    

Step 6 

The below code has been written by making use of chain of commands and this helps us to have the same color even after changing the legal entity in the home page. 


[ExtensionOf (classStr(FormRun))]

final class COLOInitForm_Extension

{

public void init()

{

next init();

appl.setTheme(CompanyInfo::find().COLOCompanyTheme);

}

} 
    

Output

Now we have color change option in Legal entities. 

Navigation: Go to Organization administration -> Organizations -> Legal entity.


Select the company and the preffered color then save the form. Below screenshot shows the selection of USMF company and Blue color.


When user selects the Legal entity as “USMF”, the color turns to “Blue”.


When user selects the Legal entity as “THMF” the color turns to “Dark orange”.


Blog written by

Rohan K Udayashankar | Dynamics 365 for Operations team.


/* H1 style */ h1 { font-size: 24px; /* Adjust the size as needed */ font-weight: normal; /* You can use 'bold', 'lighter', 'bolder', or a number */ } /* H2 style */ h2 { font-size: 20px; /* Adjust the size as needed */ font-weight: normal; /* Adjust the weight as needed */ } /* H3 style */ h3 { font-size: 18px; /* Adjust the size as needed */ font-weight: normal; /* Adjust the weight as needed */ }