I would like to know whether it is possible to implement a custom lookup (not a lookup relationship)where I can do a multiselect of users.
This selection of multiple users will result in their emails concatenated and stored in a field.
For example while creating custom views we can select multiple "Type"
After selecting the picklist values the field stores concatenated value of all the selected ones like below.
Similarly I would like to know whether I can create a multiselect lookup where I can select multiple users and after selection their emails should be concatenated and stored in a field.
Best Answer
Sure this can be quite a straightforward VisualForce page addition. I will provide some leads below which should be enough to get you to a solution. Everything should be added to your existing page / controller.
In order to have a popup-effect but keep your current state (after selecting the users, you want to return the result to the page at which you're currently at without too much effort), you can use some css styling.
Then in the popup, load a list of Users. In order to make them selectable, you could create a wrapper for the Users, adding a Boolean that indicates whether they are selected or not. Upon initializing the page, you can already load the users.
public with sharing class pageController {
}
Also add some pageReferences for the save and cancel methods. The save method will contain the logic to go through the list of users, checking whether they are selected or not, and if they are, adding their Email address to a String which you will then write back to the field.