Change Entity color based on attachment binding value

Hi All,

I have been struggling to figure this out, request your expertise please? I need to change the entity color based on the value present in one of the attachment bindings in the entity. I am struggling to loop through the entities and checking the value in attachment bindings. Would you mind sharing any of your ideas/code snippets pls?

Below is the example:

Let us say I have two entities Employee, Manager. I have added multiple attachment bindings to these entities - lets say Department, Band.  Wherever Department = "IT", I want to change that enity color to purple. Can you pls guide?

Thanks in advance.

Sandy