You need to sign in to do that
Don't have an account?
ch ranjeeth
when ever the record is created with system administrator profile it should update the Non System Admin Case field with yes otherwise No. I tried below code but its not working...
trigger contactcategory on Contact (before insert,before update)
{
set<id> set1=new set<id>();
map<id,string> map1=new map<id,id>();
for(Contact c:trigger.new)
{
set1.add(c.ownerid);
}
list<user> userlist=[select id,profile.name from user where id in:set1];
for(user u:userlist)
{
map1.put(u.id,u.profile.name);
}
for(contact c:trigger.new)
{
string s=map1.get(c.ownerid);
if(s=='System Administrator')
{
c.Non_System_Admin_Case__c='yes';
}
else
{
c.Non_System_Admin_Case__c='No';
}
}
}
{
set<id> set1=new set<id>();
map<id,string> map1=new map<id,id>();
for(Contact c:trigger.new)
{
set1.add(c.ownerid);
}
list<user> userlist=[select id,profile.name from user where id in:set1];
for(user u:userlist)
{
map1.put(u.id,u.profile.name);
}
for(contact c:trigger.new)
{
string s=map1.get(c.ownerid);
if(s=='System Administrator')
{
c.Non_System_Admin_Case__c='yes';
}
else
{
c.Non_System_Admin_Case__c='No';
}
}
}
I would suggest you start throwing System.debug statements in your code Start with debugging whether "set1" and "userList" are populated, and then go from there.
Otherwise, it's hard to tell what exactly is happening.
Also, consider changing your "Non_System_Admin_Case__c" field from a Text field to a Checkbox. A yes/no text field is silly.