7

I am working with MS Dynamics CRM 2013 and I am facing with the next issue: in CRM 2011 I disabled view and entity selection on lookup by using next jscript :

document.getElementById("lookup_id").setAttribute("disableViewPicker", "1");
document.getElementById("lookup_id").setAttribute("defaulttype", "1"); 
document.getElementById("lookup_id").setAttribute("lookuptypenames", "account:1:Account");
document.getElementById("lookup_id").setAttribute("lookuptypes", "1");

But after migration to Dynamics Crm 2013 this script doesn't work any more.

Can you help me with this issue. Thanks!

Maria Holic
  • 73
  • 1
  • 6

3 Answers3

3

Try to add "_i" with attributeId e.g
contactid is your lookup attribute name, then you should pass like

document.getElementById("contactid_i").setAttribute("disableViewPicker", "1");
document.getElementById("contactid_i").setAttribute("defaulttype", "1");
document.getElementById("contactid_i").setAttribute("lookuptypenames","account:1:Account");
document.getElementById("contactid_i").setAttribute("lookuptypes", "1");

In crm 2011 attribute input id is same as attribute name, but in crm 2013 attribute input id is attribute name plus "_i"(perhaps "_i" denotes an input).
I try this "_i" in masking and multipicker lists working perfect for 2013. Hope it helps in your case.

https://stackoverflow.com/a/21552357/1915855

Community
  • 1
  • 1
Siddique Mahsud
  • 1,453
  • 11
  • 21
0

you can also disable it in customization, In the form, when editing the lookup

select in "View selector" -> off

iair007
  • 92
  • 1
  • 3
-2

Best practice is to use the Xrm.Page object:

Xrm.Page.ui.controls.get("lookup_id").setDisabled(true);

Gareth Tucker has a great JavaScript reference for Dynamics CRM.

Using the DOM directly is unsupported in Dynamics CRM; the current code you have may break again after an update-rollup is installed. See the JavaScript Programming Best Pratices on this MSDN page.

Bvrce
  • 2,170
  • 2
  • 27
  • 45
  • 2
    I don't think that you can achieve what they are trying to do with a supported method. That code should be to disable (for example in an activity party) the possibility to choose from accounts or contacts and force the user to pick, let's say, contacts only . – Mauro De Biasio Mar 17 '14 at 04:26