locked
CRM 2011 - Disable view selector when clicking "Add Existing" button RRS feed

  • Question

  • Hi. I'm failing to find the way to do such a simple change on CRM 2011, using jscript.

    I need to disable or hide the view selector on the lookup that appears when I click the Add Existing button for an entity. That can be done when the lookup form is called from a lookup control, either by configuration or by script, as follows:

            document.getElementById([controlName]).setAttribute("defaulttype", "1")

    I need to do something like that, but I have no lookup control: in my case the form is being called from the Add Existing button associated to a subGrid. Besides, I overrode the behavior of the button, so it could use a custom view. Here's the code:

            var relName = params.gridControl.getParameter("relName"),
            roleOrd = params.gridControl.getParameter("roleOrd"),
            viewId = "{00000000-0000-0000-0000-000000000001}"; // a dummy view ID
    
        var customView = {
            fetchXml: params.fetchXml,
            id: viewId,
            layoutXml: params.layoutXml,
            name: params.name,
            recordType: params.gridTypeCode,
            Type: 0
        };
       
        var lookupItems = LookupObjects(null, "multi", params.gridTypeCode, 0, null, "", null, null, null, null, null, null, viewId, [customView]);
        
        if (lookupItems && lookupItems.items.length > 0) {
            AssociateObjects(crmFormSubmit.crmFormSubmitObjectType.value, crmFormSubmit.crmFormSubmitId.value, params.gridTypeCode, lookupItems, IsNull(roleOrd) || roleOrd == 2, "", relName);
        }

    I thought that the LookupObjects method could allow me to disable the view selector using one of its parameters. I had to try sending different values for each parameter (because I found no documentation on this function) but nothing (good) happened.

    I hope I've been clear. Thanks in advance!


    Wednesday, May 23, 2012 6:34 PM

Answers

  • I haven't tried, but you can give the following snippet a try to see if it works for your purpose. 

    LookupObjects(null, "multi", params.gridTypeCode, 0, null, "", null, null, null, null, null, null, viewId, [customView], null, null, null, null, null, null, true);

    The last parameter is to disable view selector. I haven't tried, but theoretically it should work. 


    Daniel Cai | http://danielcai.blogspot.com | @danielcai | Data Integration made easy with SSIS Integration Toolkit

    • Marked as answer by dani la morte Monday, May 28, 2012 11:35 AM
    Wednesday, May 23, 2012 11:44 PM

All replies

  • I haven't tried, but you can give the following snippet a try to see if it works for your purpose. 

    LookupObjects(null, "multi", params.gridTypeCode, 0, null, "", null, null, null, null, null, null, viewId, [customView], null, null, null, null, null, null, true);

    The last parameter is to disable view selector. I haven't tried, but theoretically it should work. 


    Daniel Cai | http://danielcai.blogspot.com | @danielcai | Data Integration made easy with SSIS Integration Toolkit

    • Marked as answer by dani la morte Monday, May 28, 2012 11:35 AM
    Wednesday, May 23, 2012 11:44 PM
  • YES! It worked! Only I had to change the value of the last parameter: "true" for "1" (strange, thought it was the same).

    LookupObjects(null, "multi", params.gridTypeCode, 0, null, "", null, null, null, null, null, null, viewId, [customView], null, null, null, null, null, null, 1);  

    Thanks a lot for your answer, Daniel. Regards!

    Monday, May 28, 2012 11:24 AM