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
sfdc integrator.ax1790sfdc integrator.ax1790 

How to select multiple contacts in lookup field.

Hi,

 

How to select multiple contacts in lookup field. Is this possible? 

 

Best Answer chosen by Admin (Salesforce Developers) 
souvik9086souvik9086

Yes you have to keep in some variable the search results.

 

For e.g after searching a contact when it appears in the box you can keep a button beside, then clicking on that will store that contact name in a variable. Again you an search for contacts, then again click that button to add the second contact in that variable. Then follow the above code I mentioned above.

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

All Answers

souvik9086souvik9086

No this is not possible. Lookup field is created on child object referncing its parent. So in the child record you can select one parent at a time. If you want to create many to many relationship, then create a junction object between the two objects.

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

sfdc integrator.ax1790sfdc integrator.ax1790

Thanks for your reply,

 

I have parent child relation with contact and even. i need to schedule a meeting for an event. to which i need to select multiple contacts for the event.

How do i accomplish this. It this possible to have any visualforce pages to get multiple records at a time.

souvik9086souvik9086

Yes you can select as many contacts as you want in the apex class and then assign that contact list to schedule a meeting for an event.

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

sfdc integrator.ax1790sfdc integrator.ax1790

Hi,

 

Can you please send me the code 

TheDoctorTheDoctor

Depending on what exactly what kind of output you require, you might also want to look into the Shared Activity functionality. It does something along the lines of what you're asking and doesn't require any code.

 

http://appexchange.salesforce.com/help/doc/en/activities_shared_about.htm

sfdc integrator.ax1790sfdc integrator.ax1790

Hi,

 

I am haveing a visualforce page which has the standard controller as "Event". I am having a input field with the value {!event.whoid}. so it gets a looup.

 

Here in the input field i need to get multiple contacts.

 

Thanks for posting.

souvik9086souvik9086

There are many scenarios for that multiple contact selection. If you want to make dynamic you have to create some text boxes in the vf where users need to input some contact name(comma separated) whom they want to schedule for event, then based on that input values you can query in the controller, thats a big functionality.

 

What you can do is create a String variable in apex named

public String contactNames{get;set;}

public List<String> selConList = new List<Contact>();

public List<Contact> conList = new List<Contact>();

public void getContacts(){

if(contactNames != NULL && contactNames != ''){

selConList = contactNames.split(',');

if(selConList.size()>0){

conList = [SELECT id, name FROM Contact WHERE name in :selConList];

}

}

}

 

Then you can get those contacts in conList which you want to schedule for event.

 

VF

<apex:inputtext value="{!contactNames}"/>

<apex:commandButton action="{!getContacts}" value="Select Contacts"/>

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

 

sfdc integrator.ax1790sfdc integrator.ax1790

Hi 

souvik9086souvik9086

YEs as I mentioned there are many scenarios you can do another workaround like create a search box for contact names and when the user types one two words for the contact then it displays the full name and from there you can work with those.

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

sfdc integrator.ax1790sfdc integrator.ax1790

hi 


souvik9086 wrote:

YEs as I mentioned there are many scenarios you can do another workaround like create a search box for contact names and when the user types one two words for the contact then it displays the full name and from there you can work with those.

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks


souvik9086souvik9086

Yes you have to keep in some variable the search results.

 

For e.g after searching a contact when it appears in the box you can keep a button beside, then clicking on that will store that contact name in a variable. Again you an search for contacts, then again click that button to add the second contact in that variable. Then follow the above code I mentioned above.

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

This was selected as the best answer
Rithu Nuthalganti 10Rithu Nuthalganti 10
@Souvik9086 Is this possible through many to many relationship between Contact and Event?

Thanks
Rithu