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
Shephali SwarnkarShephali Swarnkar 

how to assign selected contact list to user

I have a senario as follow
1. Add users.
2.Having a list of contacts as owner.
3.Assign a set of contact list to perticular user and another different set to one other user.
                                                How to achieve this so that each user can see only assigned contacts not others contact.
AB TestAB Test
I am not able to get your question completely, But please find my solution below and see if it helps : 

Add Users : This can be done using standard UMS.

3.Assign a set of contact list to perticular user and another different set to one other user.-->
          You can change the ownerId of the contact list to specified user to which you wanna give access using Apex. 
Also just ensure that contact OWD sharing setting is private so that only owner gets the access of the record.
And don't forget to keep the controller if you are using any as 'with sharing'

Hope it Helps.

 Please mark the answer as best answer or like it if it helps :)
Shephali SwarnkarShephali Swarnkar
Hi AB Test,
      Thanks for reply.I am using two standard objects 'contacts' and 'user'. In contact i am adding my contacts and through user(object) am creating users. I have 3 users who have access to contact object. Now i need to assign each user different contacts list out from contact's records and these user can see only thier assigned contacts records list not others.
       How to do this????
Note: Assigning list of contacts to one user at a time and then other list to other user.... not simulteniously.
AB TestAB Test
Hi 

 Say you have created the contact list of all the created contacts. Then just traverse through that list using for loop and just change the ownerId field on the contact with the desired userId and update the contact list after the loop.

Also just ensure that contact OWD sharing setting is private so that only owner gets the access of the record.
And don't forget to keep the controller if you are using any as 'with sharing'


Hope it Helps.

 Please mark the answer as best answer or like it if it helps :)
 
Shephali SwarnkarShephali Swarnkar
Thank you AB Test,
        Can you provide me apex code to achieve the same.as i have set OWD setting as private on contact object.
I am enlisting the contact list with chekboxes(using wrapper class) so that admin can choose multiple contacts and enlisting the users list with radio buttons so that user can choose only one user to assign the selected contacts.
what would be the apexcode on button click.???