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

Error message while returning multiple selected contact from custom lookup to base page

I have one custom event vf page which contains one lookup field Contact, On clicking of lookup icon on Contact it will open my custom lookup page. I am able to select multiple contact and saving them in one string. So on click of button I'm returning the selected contact in my base page, but while returning I'm getting following error. "The name can only contain underscores and alphanumeric characters. It must begin with a letter and be unique, and must not include spaces, end with an underscore, or contain two consecutive underscores."

Below is my Sample code:

Command Button:
<apex:commandButton value="Done" action="{!done},javascript:top.window.opener.contactLookup('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!contactId}','{!contactName}',false)" ></apex:commandbutton>

Here ContactId contains selected contact Id and ContactName contains selected contact Name, these two strings are returning value.

public String selectedContactName { get; set; }
public String contactId {get;set; } 
    public String getDone() {
        Boolean first = true;
        for ( SelectOption so : selectedContacts ) {
            if (!first) {
                selectedContactName += ', ';
                contactId += ', ';
            selectedContactName = so.getLabel();
            contactId = so.getValue();
            selectedContactName += so.getLabel();    
            contactId += so.getValue();
            first = false;
        return selectedContactName ;

ShashankShashank (Salesforce Developers) 
Please let me know if you are still facing this issue or if you found a solution.