Answered by:
Change default view for PartyList type field.

Question
-
In the Phone entity (CRM 2011) the Recipient field is of type "PartyList". When clicking on the dialog lookup it defaults to "Accounts" and I would like it to default to "Contacts". Is there a JavaScript function or XML change that can be made to make "Contacts" the default? I've been unable to find anything like this for CRM 2011.
Thanks,
John.
JC- Moved by Kimberlee Johnson Thursday, June 2, 2011 1:12 PM jscript question (From:Dynamics CRM)
Thursday, June 2, 2011 12:57 PM
Answers
-
Hi John,
Here is the Script to filter the types in the Party list field.
//To restrict the types in party list
document.getElementById("to").setAttribute("lookuptypes", "2");
//to set the default type
document.getElementById("to").setAttribute("defaulttype", "2");Thanks and Regards
Ramu
- Proposed as answer by Janu_m Thursday, June 2, 2011 7:25 PM
- Marked as answer by DavidJennawayMVP, Moderator Friday, August 19, 2011 4:33 PM
Thursday, June 2, 2011 7:25 PM
All replies
-
Hi John,
Here is the Script to filter the types in the Party list field.
//To restrict the types in party list
document.getElementById("to").setAttribute("lookuptypes", "2");
//to set the default type
document.getElementById("to").setAttribute("defaulttype", "2");Thanks and Regards
Ramu
- Proposed as answer by Janu_m Thursday, June 2, 2011 7:25 PM
- Marked as answer by DavidJennawayMVP, Moderator Friday, August 19, 2011 4:33 PM
Thursday, June 2, 2011 7:25 PM -
Hi Ramu,
I was working on the same thing in 2011 and have a small issue. I am replacing the entities in the to field with several custom entities. It all works OK, just that when the values are returned to the lookup control, the do not display the correct icons of the custom entities. See code below:
var to = document.getElementById("to");
to.setAttribute("lookuptypes", "2," + etc_list + "," + etc_committee);
to.setAttribute("lookuptypeicons", "/_imgs/ico_16_2.gif,/CRM2011/WebResources/xrm_icolist16,/CRM2011/WebResources/xrm_icocom16");
to.setAttribute("defaulttype", etc_list);Any suggestions?
Thanks.
- Edited by Aric Levin Monday, October 3, 2011 9:17 PM
Monday, October 3, 2011 9:14 PM -
Ramu -
the code works brilliantly except for when a person decides to change from the new default lookup (say Contacts) to another lookup (Companies) then back to the original (Contacts). Then there is an error of "This object does't support this property or method". Here is my modified version (I am using parameters so I an use in in more than one place on the form):
function SetPartyList(thisField, thisItem) { document.getElementById(thisField).setAttribute("defaulttype", thisItem); }
Any ideas of what I need to do or where I am screwing up? Do I need to set an OnChange to the field?Thanks!
JoyFriday, January 27, 2012 2:16 PM -
Even i am facing the same problem similar to the one mentioned it the above thread in MSCRM 2011, Does anyone has solution, please help us.
Wednesday, February 22, 2012 12:03 PM -
Hi Ramu,Joy
Below code worked for me, while setting default to contact and user in the partylist lookup for "to" attribute in email activity.
not getting the error "This object does't support this property or method"
crmForm.all.to.setAttribute(“lookuptypes”, “2,8″); //show contact and user
crmForm.all.to.setAttribute(“lookuptypeIcons”, “/_imgs/ico_16_2.gif :/_imgs/ico_16_8.gif”);//set the icons
crmForm.all.to.setAttribute(“defaulttype”, “2″);
Xrm.Page.getControl(“to”).setDefaultView(“00000000-0000-0000-00AA-000010001003″); //GUId for default contact ViewRegards
Surendra
- Proposed as answer by Surendra Iyer Monday, February 27, 2012 1:49 PM
- Edited by Surendra Iyer Monday, February 27, 2012 2:02 PM
Monday, February 27, 2012 1:48 PM -
To what form are you adding the javascript? I want to default phone calls to the Contact lookup so I added the web resource to the Phone Call entity form OnLoad event. Unfortunately, the recipient lookup window keeps defaulting to Accounts
function setLookupContact() { document.getElementById("to").setAttribute("defaulttype","2"); Xrm.Page.getControl("to").setDefaultView("A2D479C5-53E3-4C69-ADDD-802327E67A0D"); }
Monday, June 3, 2013 6:42 PM -
Hi;
The code works for CRM 2011, but not works for CRM 2013, anyway make it works for CRM 2013
Thanks!
Monday, December 30, 2013 3:02 PM