Power Community

Power Community

Get Entity Colors in PowerApps Component Framework


PowerApps Component Framework has numerous methods that are useful to developers in several ways. In developing one of my PCF controls, I ran across a case in which entity colors were required in our control.

I obtained this using the conventional method of calling the getEntityMetadata() for the respective entity and obtaining the EntityColor from it.

let metadata = await context.utils.getEntityMetadata("account");
let entityColor = metadata.EntityColor;

However, this leads to sending requests to the CRM as it is asynchronous, which usually degrades the performance of our PCF control.


In this case, the getEntityColor method comes to the rescue, where no request is sent to CRM. Thus, enhancing the performance of our PCF control. This method can be found in theming under context.


Using the above method, we can get the entity color in HEX format as we add them in customizations.


As shown in the below screenshot, we have set the color for the account entity as #794300.



Let us consider, we are working on building a dropdown in PCF which shows the entities/tables of CRM. Users can select any of these entities from the dropdown for further operations.

However, just showing entity names will make it look dull and uninteresting. So, to lighten up this scenario we will add a colorful box, which will be colored with the respective entity colors.

Another scenario from this can be the user may need to know the color of the entity before selecting the entity option.


Here, we use a Dropdown component of Fluent UI and render the options in it.

return (
//method to render an option into the dropdown field
const _renderOption = (option: any): any => {
let entityName = option.key;
return (
{ //@ts-ignore } {/* text of an option set field */} {option.text}

); }

Note: This method is not documented so use a fallback for this method in terms of any future untoward.


In this way, we learned how to get the entity color without sending a request with getEntityMetadata()

Business Process Checklist (2)

This post was originally published on this site

- Advertisement -spot_img


Please enter your comment!
Please enter your name here

- Advertisement - Advertisement

Latest News

Plugin Error – Security accessibility of the overriding method must match the security accessibility of the method being overridden – Quick Fix

Hi Folks, I recently came across the above error for one of my Dynamics 365 Plugins…this blog talks about applying...

More Articles Like This

- Advertisement -spot_img