function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Refer below link which has the sample code for the same.
https://success.salesforce.com/ideaView?id=087300000006tto
Please mark it as Solved if my reply was helpful. It will make it available for other as the proper solution.
Thanks and Regards
Sandhya
Please refer to the below code. Hope this helps you.
//Apex Class
public class CustomerPortalUpdate {
public static void updateUserLName(List<Contact> contactList)
{
Set<Id> contactIdSet = new Set<Id>();
for(Contact cont: contactList)
{
contactIdSet.add(cont.Id);
}
List<User> userList = new List<User>();
userList = [SELECT ContactId,LastName FROM User WHERE ContactId IN:contactIdSet];
List<User> updateUserList = new List<User>();
for(Contact con_iterate: contactList)
{
for(user u_iterate: userList)
{
u_iterate.LastName = con_iterate.LastName;
updateUserList.add(u_iterate);
}
}
update updateUserList;
}
}
//Trigger
trigger UpdateCustomerPortal on Contact (after update) {
CustomerPortalUpdate.updateUserLName(Trigger.New);
}
Please mark it as best answer if it helps you.
Thank You,
Ajay Dubedi