function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

If Condition



I am attempting to change the color of text in a visualforce page.  I am doing the logic in the contoller and passing the variable to the VF page.  The problem is I am comparing a lookup field to a set of IDs.  If the ID is not in the list, I want to change the color.  I think I can get there with a nested for loop but it is not best practice.  Any input on how to acheive this is greatly appreciated.


public String getcolor1(){
LIST<user> users= new list<user>();
users = [select id, name from user where = 'Executive' or'Ops Team 8'];
set<id> uid = new set<id>();

for(user us: users){


String color='red';
list<carrier__c> Ids = [select id, team__c from carrier__c where team__c != NULL];
//system.debug('***** cid = '+cid);
system.debug('***** uid = '+uid);
system.debug('***** Ids = '+Ids);

for(carrier__c car: ids){
if(car.team__c ! NOT IN: uid){   //  This is incorrect logic.  comparing an ID (lookup field) to a set of IDs.  Perhaps I should have a nested for loop?
// }
return color;




Currently everything in the list is blue and some should be red.

Best Answer chosen by Admin (Salesforce Developers)