locked
CRM 2013:Issue with addCutomView for Connect To lookup on Connection form RRS feed

  • Question

  • Hi All,

    I tried to setup "Account" entity as default for Connect To lookup and also to filter records using addCustomView but it's not working. It shows Contact lookup view as default. Please find below the JS:

    var viewId = Xrm.Page.getControl("record2id").getDefaultView();

                var entityName = "account";

                var viewDisplayName = "Accounts connected to";

                var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>" +

                  "<entity name='account'>" +

                   " <attribute name='name' />" +

                    "<attribute name='accountid' />" +

                    "<order attribute='name' descending='false' />" +

                    "<filter type='or'>" +

                     " <condition attribute='tenanttype' operator='eq' value='1' />" +

                     " <condition attribute='tenanttype' operator='eq' value='2' />" +

                    "</filter>" +

                  "</entity>" +

                "</fetch>";

                var layoutXml = "<grid name='resultset' object='1' jump='name' select='1' icon='1' preview='1'>" +

                 "<row name='result' id='accountid'>" +

                     "<cell name='name' width='300' />" +

                  "</row>" +

                  "</grid>";

                   document.getElementById("record2id").setAttribute("defaulttype", "1");

                    document.getElementById("record2id").setAttribute("lookuptypes", "1");

                Xrm.Page.getControl("record2id").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);

               //  Xrm.Page.getControl("record2id").setDefaultView(viewId);

                document.getElementById("record2id").disableViewPicker = 1;

    Please let me know about solution, if any.

    Thank you.

    JayshriP


    • Edited by JayshriP Wednesday, June 4, 2014 1:34 PM CRM version mentioned
    Wednesday, June 4, 2014 1:33 PM

Answers

  • Issue is resolved now. Previously I was trying to add custom view using OnLoad event handler but now I added custom view in Pre Search event handler.

    Xrm.Page.getControl(

    "record2id").addPreSearch(filterConnectToRecords);

    It worked.

    Thank you.

    JayshriP

    • Marked as answer by JayshriP Thursday, July 3, 2014 5:36 AM
    Thursday, July 3, 2014 5:36 AM