You need to sign in to do that
Don't have an account?
If Condition
Greetings,
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 userrole.name = 'Executive' or userrole.name='Ops Team 8'];
set<id> uid = new set<id>();
for(user us: users){
uid.add(us.id);
}
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?
color='blue';
}
// }
}
return color;
}
Currently everything in the list is blue and some should be red.
Use contains: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_System_Set_instance_methods.htm