+ Start a Discussion
SFDC_DeveloperSFDC_Developer 

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.

Method:
public String selectedContactName { get; set; }
public String contactId {get;set; } 
    public String getDone() {
        Boolean first = true;
        for ( SelectOption so : selectedContacts ) {
            if (!first) {
                selectedContactName += ', ';
                contactId += ', ';
            }
            if(first){
            selectedContactName = so.getLabel();
            contactId = so.getValue();
            }else{
            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.