Answered by:
CRM 2011 : Lookup with Multiple selection

Question
-
Hi All,
I have lookup name call as Broker.. for this i want to select Multiple selection...
How can i implement it.. as of now i can able to select only one.
But In build Email Multiple To option we can select.. same way i want select in Broker also in my entity how ?
any one help me out
Rammohan
Tuesday, May 29, 2012 7:30 AM
Answers
-
Hello,
In case you have already created lookup - you would not be able to achieve your goal in supported way.
You should try to create custom activity. I haven't tried it so you can try.
- Marked as answer by Andrii ButenkoMVP, Moderator Wednesday, May 30, 2012 4:16 PM
Tuesday, May 29, 2012 7:49 AMAnswerer -
Hi,
This is not possible to build a custom multiple selection lookup.
You could try to code some specific silverlight or HTML/JS web resource to handle the behavior expected
My blog : http://mscrmtools.blogspot.com
Did you try the new CrmDiagTool for Microsoft Dynamics CRM 2011 ? If not, follow me
Upgraded tools for Dynamics CRM 2011!
View Layout Replicator | Searchable Property Updater | Ribbon Browser | SiteMap Editor | JavaScript Web Resource Manager | Role updater- Marked as answer by Andrii ButenkoMVP, Moderator Wednesday, May 30, 2012 4:16 PM
Tuesday, May 29, 2012 7:49 AMModerator -
Don´t forget in email TO, FROM, CC, BCC we have partylists and not lookups.
The only way you can work around would be n:n relationsship where you can select multiple records to join one record (like the connection or relationship entity). But this won´t end up in a single line of comma or delimiter separated records like on email form.
Carsten Groth http://carstengroth.wordpress.com Microsoft Dynamics Certified Technology Specialist
- Marked as answer by Andrii ButenkoMVP, Moderator Wednesday, May 30, 2012 4:16 PM
Tuesday, May 29, 2012 8:15 AM -
Hi,
Instead of using lookup field.Use multiselect picklist where you have the option to choose multiple value at the same time.
You can refer following blogs for implementing multipicklist.
http://www.techadv.com/blog/adding-a-multi-select-picklist-to-microsoft-dynamics-crm-2011.html
http://varghesedanny.com/2011/01/09/multi-select-picklists/
http://crmxpg.nl/wp/2010/10/05/how-to-create-a-multi-select-picklist-in-ms-crm/
Yusuf
- Marked as answer by Andrii ButenkoMVP, Moderator Wednesday, May 30, 2012 4:16 PM
Tuesday, May 29, 2012 10:26 AM -
Hi,
You can use the below code to implement multiple selection in Lookup field.
// I created a one multiline text box to save the lookup values.
// set the multiline textbox visible equal to false.lookup == > Lookup Field Name
description ==> Multiline Textbox
type == > // To get the type
// Go to your form Customization ---> double click on your lookup--->Details--->Edit--->Here you can see typefunction Multilookup_onload(lookup, description, type) {
document.getElementById(lookup).setAttribute("lookupstyle", "multi");
if (Xrm.Page.ui.getFormType() != 1) {
var hor_arry = new Array();
var test = Xrm.Page.getAttribute(description).getValue();if (test != null) {
hor_arry = test.split(";");
var value = new Array();
var i = 0;
var j = 0;
var id = new Array();
var name = new Array();
var typename = type;for (i = 0, j = 0; i < (hor_arry.length - 1); i = i + 2, j++) {
id[j] = hor_arry[i + 1];
name[j] = hor_arry[i];
}for (i = 0; i < ((hor_arry.length - 1) / 2); i++) {
value[i] = new Object();
value[i].id = id[i];
value[i].name = name[i];
value[i].typename = typename;
}crmForm.all[lookup].DataValue = value;
}
}
}Hope this will help you.... :-)
Regards,
Priyank Jain- Proposed as answer by Priyank Jain (CRM) Tuesday, July 16, 2013 7:30 AM
- Marked as answer by Rammohan Ammiti Tuesday, July 16, 2013 9:05 AM
Tuesday, July 16, 2013 7:11 AM -
Hi Rammohan,
Try to use below code on save event of the entity,
function save()
{
var value = crmForm.all["Your lookup Schema Name"].DataValue;
var s;
var temp="";for (s=0;s<value.length;s++)
{
var temp2="";temp2=value[s].name+";"+value[s].id+";";
temp=temp+""+temp2;
}Xrm.Page.getAttribute("new_textbox").setValue(temp);
Xrm.Page.getAttribute("Your lookup Schema Name").setValue(null);
document.getElementById("Your lookup Schema Name").setAttribute("lookupstyle", "single");
}Hope this will help you..
If both codes working fine than please mark both as answer.Regards,
Priyank Jain- Marked as answer by Rammohan Ammiti Tuesday, July 16, 2013 9:05 AM
Tuesday, July 16, 2013 8:38 AM
All replies
-
Hello,
In case you have already created lookup - you would not be able to achieve your goal in supported way.
You should try to create custom activity. I haven't tried it so you can try.
- Marked as answer by Andrii ButenkoMVP, Moderator Wednesday, May 30, 2012 4:16 PM
Tuesday, May 29, 2012 7:49 AMAnswerer -
Hi,
This is not possible to build a custom multiple selection lookup.
You could try to code some specific silverlight or HTML/JS web resource to handle the behavior expected
My blog : http://mscrmtools.blogspot.com
Did you try the new CrmDiagTool for Microsoft Dynamics CRM 2011 ? If not, follow me
Upgraded tools for Dynamics CRM 2011!
View Layout Replicator | Searchable Property Updater | Ribbon Browser | SiteMap Editor | JavaScript Web Resource Manager | Role updater- Marked as answer by Andrii ButenkoMVP, Moderator Wednesday, May 30, 2012 4:16 PM
Tuesday, May 29, 2012 7:49 AMModerator -
Hi
It's already available right ? why it's not possible?
Email entity we have field callead as TO, CC, BCC in that Multiple users we can able to select and Multiple accounts and contacts we can able to select over there...
that way any one can suggest it..
_Regards,
Ammiti
Rammohan
Tuesday, May 29, 2012 7:53 AM -
Because Microsoft doesn't let us create such type of lookup... even if it is technically available in the platform
We are all aware this is a limitation that should be removed but by now, you can't do anything supported...
My blog : http://mscrmtools.blogspot.com
Did you try the new CrmDiagTool for Microsoft Dynamics CRM 2011 ? If not, follow me
Upgraded tools for Dynamics CRM 2011!
View Layout Replicator | Searchable Property Updater | Ribbon Browser | SiteMap Editor | JavaScript Web Resource Manager | Role updaterTuesday, May 29, 2012 7:56 AMModerator -
Don´t forget in email TO, FROM, CC, BCC we have partylists and not lookups.
The only way you can work around would be n:n relationsship where you can select multiple records to join one record (like the connection or relationship entity). But this won´t end up in a single line of comma or delimiter separated records like on email form.
Carsten Groth http://carstengroth.wordpress.com Microsoft Dynamics Certified Technology Specialist
- Marked as answer by Andrii ButenkoMVP, Moderator Wednesday, May 30, 2012 4:16 PM
Tuesday, May 29, 2012 8:15 AM -
Hi carsten,
Please explain bit more how can i build this one?
I mean step by step..
I create the N;N relation ship for the another enity but i am not able see.. so, pls explain bit more clear to achieve the task
Rammohan
Tuesday, May 29, 2012 8:42 AM -
Hi,
Instead of using lookup field.Use multiselect picklist where you have the option to choose multiple value at the same time.
You can refer following blogs for implementing multipicklist.
http://www.techadv.com/blog/adding-a-multi-select-picklist-to-microsoft-dynamics-crm-2011.html
http://varghesedanny.com/2011/01/09/multi-select-picklists/
http://crmxpg.nl/wp/2010/10/05/how-to-create-a-multi-select-picklist-in-ms-crm/
Yusuf
- Marked as answer by Andrii ButenkoMVP, Moderator Wednesday, May 30, 2012 4:16 PM
Tuesday, May 29, 2012 10:26 AM -
Hi,
You can use the below code to implement multiple selection in Lookup field.
// I created a one multiline text box to save the lookup values.
// set the multiline textbox visible equal to false.lookup == > Lookup Field Name
description ==> Multiline Textbox
type == > // To get the type
// Go to your form Customization ---> double click on your lookup--->Details--->Edit--->Here you can see typefunction Multilookup_onload(lookup, description, type) {
document.getElementById(lookup).setAttribute("lookupstyle", "multi");
if (Xrm.Page.ui.getFormType() != 1) {
var hor_arry = new Array();
var test = Xrm.Page.getAttribute(description).getValue();if (test != null) {
hor_arry = test.split(";");
var value = new Array();
var i = 0;
var j = 0;
var id = new Array();
var name = new Array();
var typename = type;for (i = 0, j = 0; i < (hor_arry.length - 1); i = i + 2, j++) {
id[j] = hor_arry[i + 1];
name[j] = hor_arry[i];
}for (i = 0; i < ((hor_arry.length - 1) / 2); i++) {
value[i] = new Object();
value[i].id = id[i];
value[i].name = name[i];
value[i].typename = typename;
}crmForm.all[lookup].DataValue = value;
}
}
}Hope this will help you.... :-)
Regards,
Priyank Jain- Proposed as answer by Priyank Jain (CRM) Tuesday, July 16, 2013 7:30 AM
- Marked as answer by Rammohan Ammiti Tuesday, July 16, 2013 9:05 AM
Tuesday, July 16, 2013 7:11 AM -
Hi Priyank,
while selecting the multiple lookup values it's working..but while saving the record it's getting crm error
Like
Error
an error has occured.
Try this action again.if the problem continues, check the Mcrosoft dynamics CRM community for solutions or contact your oranization MSCRM Administrator..finally you can contact Microsoft Support
Try again cancel
Rammohan
Tuesday, July 16, 2013 7:51 AM -
Hi Rammohan,
Try to use below code on save event of the entity,
function save()
{
var value = crmForm.all["Your lookup Schema Name"].DataValue;
var s;
var temp="";for (s=0;s<value.length;s++)
{
var temp2="";temp2=value[s].name+";"+value[s].id+";";
temp=temp+""+temp2;
}Xrm.Page.getAttribute("new_textbox").setValue(temp);
Xrm.Page.getAttribute("Your lookup Schema Name").setValue(null);
document.getElementById("Your lookup Schema Name").setAttribute("lookupstyle", "single");
}Hope this will help you..
If both codes working fine than please mark both as answer.Regards,
Priyank Jain- Marked as answer by Rammohan Ammiti Tuesday, July 16, 2013 9:05 AM
Tuesday, July 16, 2013 8:38 AM -
MSCRM 2011 Multi Lookup:
In MS CRM by default it provides the look up to select a single record in it. If we want to select more than one record with in the same llo up we need to do some Javs Script coding on that look up .
Here we can trigger the script events in Onload and Onsave.
Steps to Follow to setup a Multi Value Look Up:
1) Form shuold have the One Lookup .
2) Shoold place on Multi Line Text Field on the form.
Process:
Create On Javascript Web Resource and Paste the Following Code, then add it to the Web Resource Library.
Add the web resource to your Form, and call the functions in Onload and OnSave events is as follows.
Onload Event Code:
//Call this Function on Form Load Event
function load() {
document.getElementById(” Lookup Schema Name”).setAttribute(“lookupstyle”, “multi”);
document.getElementById(” Lookup Schema Name”).setAttribute(“_lookupstyle”, “multi”);if (Xrm.Page.ui.getFormType() != 1) {
var data = new Array();
// I created a one multiline text box to save the lookup values.
// set the multiline textbox visible equal to false.
var store = Xrm.Page.getAttribute(” Multi line text Schema Name”).getValue();if(store!=null)
data = store.split(“;”);var typename = “Target Record Type”;
var arr = new Array();
var i = 0;
var j = 0;for (i = 0; i < ((data.length – 1) / 2); i++) {
arr[i] = new Object();
arr[i].name = data[j];
arr[i].id = data[j + 1];
arr[i].typename = typename;
j++;
j = j + 1;
}
if(i!=0 && j!=0)
crmForm.all[" Lookup Schema Name"].DataValue = arr;
}
}//Call this Function on Save Event
function save() {
var value = crmForm.all[" Lookup Schema Name"].DataValue;
var s;
var temp = “”;for (s = 0; s < value.length; s++) {
var temp2 = “”;
temp2 = value[s].name + “;” + value[s].id + “;”;
temp = temp + “” + temp2;
}
Xrm.Page.getAttribute(” Multi line text Schema Name”).setValue(temp);
Xrm.Page.getAttribute(” Lookup Schema Name”).setValue(null);
document.getElementById(” Lookup Schema Name”).setAttribute(“lookupstyle”, “single”);
}Warm Regards, Suresh Kumar D
Saturday, August 24, 2013 10:08 AM -
Hi,
is the above code works for CRM 2013.
I need multi select lookup functionality in CRM Fall-2013, how to achieve this.
Please can anyone help me to resolve this issue.Nagaraj
Friday, October 18, 2013 2:02 PM