CRM 2011: Disable Search in Lookup
-
Sunday, May 22, 2011 6:47 AM
Hi
I wanted to deny a user from selecting non related records in Lookup. Though I am able to filter the lookup with a FetchXML query, and set it as default view, still the user can select some other System View and select a record. So, i need to disable the search and View selector in lookup. How can i do this.
PS: I didn't used the Form Editor based lookup because, these two entities are not related directly.
Thanks & Regards, Johninfant
All Replies
-
Sunday, May 22, 2011 7:03 AMIf I understand you correctly, by customizing the system views of your entity, you can include filters and add or remove find columns from the view.
Islam Eldemery
http://idemery.net

-
Sunday, May 22, 2011 7:34 AM
Hi Islam
Thanks for reply. But what i wanted cannot be accomplised in Default System View. I am using a FetchXML query and LayoutXML to define the lookup attributes. this successfully filters the records and i can specify wanted columns in LayoutXML.. so that's not a problem.
My Problem was, I wanted to disable or hide the search box and view selector in Lookup window.
My colleague suggested me to use crmForm.all.lookupfield.lookupbrowse = 0 or 1 to enable or disable. But the problem, if i use this method, my custom view is not set. I mean records are not filtered.Anyhow, i found out a way to do this.Use,Xrm.Page.ui.controls.get("lookupname").$0_3._element.allowFilterOff = 0; //Disables the use from Switching off the filter
Xrm.Page.ui.controls.get("lookupname").$0_3._element.disableViewPicker = 1; //Disables the view selectorXrm.Page.ui.controls.get("lookupname").$0_3._element.disableQuickFind = 1; //Disables the search boxThough this is unsupported, i am using this for time being. Kindly let me know, if any supported way of customization is available.
Thanks & Regards, Johninfant- Marked As Answer by Johninfant Sunday, May 22, 2011 7:34 AM
-
Thursday, July 07, 2011 1:30 AM
Hi John,
can you please assist? I am attempting to do the exact same thing. Can you please tell me 'where' in the code you placed the;
function filterfromfieldlookup() {
// View ID –> Generate and Assign a new guid.var viewId = "{00000000-0000-0000-00AA-000010001019}";
// Set the entity name
var entityName = "systemuser";
// Give a meaningful name to the custom view
var viewDisplayName = "Enabled Users";// Create the Advanced find query and download the fetch xml
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
"<entity name='systemuser'>" +
"<attribute name='fullname' />" +
"<attribute name='title' />" +
"<attribute name='address1_telephone1' />" +
"<attribute name='businessunitid' />" +
"<attribute name='siteid' />" +
"<attribute name='systemuserid' />" +
"<order attribute='fullname' descending='false' />" +
"<filter type='and'>" +
"<condition attribute='isdisabled' operator='eq' value='0' />" +
"</filter>" +
"</entity>" +
"</fetch>";// specify the layout for the results and which field to display
var layoutXml = "<grid name='resultset' " +
"object='1' " +
"jump='name' " +
"select='1' " +
"icon='1' " +
"preview='1'>" +
"<row name='result' " +
"id='systemuserid'>" +
"<cell name='fullname' " +
"width='100' />" +
"</row>" +
"</grid>";
// specify the schemaname of the lookup control
var lookupControl = Xrm.Page.ui.controls.get('to');
// set the parameterslookupControl.addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);
lookupControl.$0_3._element.allowFilterOff = 0; //Disables the use from Switching off the filter
lookupControl.$0_3._element.disableViewPicker = 1; //Disables the view selector
lookupControl.$0_3._element.disableQuickFind = 1; //Disables the search box}
Xrm.Page.ui.controls.get("lookupname").$0_3._element.allowFilterOff = 0; //Disables the use from Switching off the filter
Xrm.Page.ui.controls.get("lookupname").$0_3._element.disableViewPicker = 1; //Disables the view selectorXrm.Page.ui.controls.get("lookupname").$0_3._element.disableQuickFind = 1; //Disables the search boxcode? my view does default - however I get errors on reference to the .$0_3._element.*how do I find out my elements?ps I have also enabled Jquery.Thanks alot in advanced - my code is included below: -
Thursday, July 07, 2011 9:59 AM
Hi Owen
Are you getting any object, when you execute Xrm.Page.ui.controls.get("lookupname") ??? Which Rollup Version are you in..???
Thanks & Regards, Johninfant -
Friday, April 27, 2012 5:40 AM
Hi John,
Thanks for given code for disable lookup view.Its working fine.
But i need supported code for disable the view picker for custom lookup.
if you know anything ,please let me know .
Regards,
jayakrishna.M
-
Thursday, May 03, 2012 4:47 AM
Hi Jai
The above code works with UR1 only. Use the below code instead.
crmForm.all.[lookupname].disableQuickFind = 1;
crmForm.all.[lookupname].disableViewPicker = 1;
Thanks,
John
Thanks & Regards, Johninfant
- Marked As Answer by Johninfant Thursday, May 03, 2012 7:33 AM