You can use bleow trigger to solve your problem.. you can also use workflow or formula fields as Manj_SFDC suggested but the problem with workflow or formula field is you need to hardcode the profileID . or else you can try with Contact owner profile.
trigger updatecheckbox on Contact (after update) {
set<id> ids=trigger.newMap.keySet();
List<contact>con = [select id,fax,checkbox__c,email,phone from contact where id=:ids];
user u=[select id,email,profile.Name,phone from user where id=:UserInfo.getUserId()];
list<contact> conlist=new List<contact>();
for(Contact c:con){
if(c.email==u.email&& u.profile.Name=='Customer user' && c.checkbox__c!=true ){
c.checkbox__c=true;
conlist.add(c);
}
}
if (!conlist.isEmpty()){
update conlist;
}
}
please let me know what does this query user u=[select id,email,profile.Name,phone from user where profile.Name = 'YMCA Community User' Limit 1]; returning?
Hi Niven, change the line 07 from user u=[select id,email,profile.Name,phone from user where profile.Name = 'YMCA Community User'Limit 1]; to user u=[select id,email,profile.Name,phone from user where profile.Name = 'YMCA Community User' and id=:UserInfo.getUserId() ]; login with the user who has the YMCA Community User' profile
please mark the qustion as solved if this helps you Good luck !
It should work..not sure how are you testing..just log in as a community user and try to update the contact record and check if the checkbox should be check..I have tested and its working for me..
I guess you just need to check the user.contactid should not be null...try below code and let me know if this works for you..
--
Thanks,
Prashant
All Answers
please mark this as solved if this helps you
You can use bleow trigger to solve your problem.. you can also use workflow or formula fields as Manj_SFDC suggested but the problem with workflow or formula field is you need to hardcode the profileID . or else you can try with Contact owner profile. --
Thanks,
Prashant
user u=[select id,email,profile.Name,phone from user where profile.Name = 'YMCA Community User' Limit 1];
returning?
I guess you just need to check the user.contactid should not be null...try below code and let me know if this works for you..
--
Thanks,
Prashant
user u=[select id,email,profile.Name,phone from user where profile.Name = 'YMCA Community User'Limit 1];
to
user u=[select id,email,profile.Name,phone from user where profile.Name = 'YMCA Community User' and id=:UserInfo.getUserId() ];
login with the user who has the YMCA Community User' profile
please mark the qustion as solved if this helps you
Good luck !
It should work..not sure how are you testing..just log in as a community user and try to update the contact record and check if the checkbox should be check..I have tested and its working for me..
--
Thanks,
Prashant