Thursday, July 23, 2015

Filter Lookup

Hi All,

We can filter the Lookup based on below code in CRM 2011 but in CRM 2013 and CRM 2013 we cannot achive this

Note: Replace "to" with "field Name"

if (crmForm.all.to!= null) {
            lookuptypeIcons = '/_imgs/ico_16_2.gif:/_imgs/ico_16_8.gif';
            lookuptypenames = 'contact:2:Contact,systemuser:8:User';
            lookuptypes = '2,8';

            crmForm.all.to.setAttribute("defaulttype", "2");
            crmForm.all.to.setAttribute("lookuptypes", lookuptypes);
            crmForm.all.to.setAttribute("lookuptypenames", lookuptypenames);
            crmForm.all.to.setAttribute("lookuptypeIcons", lookuptypeIcons);
            Xrm.Page.getControl("to").setDefaultView("A2D479C5-53E3-4C69-ADDD-802327E67A0D"); //GUId for  default View            
        }

we can achive this by using below code

 $("#to").focus(function () {
    var toLookUp = $("img[attrName='to']");
    var lookuptypeIcons = '/_imgs/ico_16_2.gif?ver=828891367:/_imgs/ico_16_8.gif??ver=828891367';
  var lookuptypenames = 'contact:2:Contact,systemuser:8:User';
    lookuptypes = '2,8';
    if (toLookUp.length > 0) {
        toLookUp[0].setAttribute("lookuptypenames", "contact:2:Individual,systemuser:8:User");
        toLookUp[0].setAttribute("lookuptypes", "2,8");
        toLookUp[0].setAttribute("lookuptypeIcons", lookuptypeIcons);
        toLookUp[0].setAttribute("createpermissiondictionary", "contact:true,systemuser:true");
        toLookUp[0].setAttribute("DefaultViewId", "A2D479C5-53E3-4C69-ADDD-802327E67A0D");
        toLookUp[0].setAttribute("defaulttype", 2);
    }
});    

No comments:

Post a Comment

Bulk Delete Operation in Dataverse/MSCRM

  Introduction: In this blog we will see how to Bulk Delete Operation in Dataverse/MSCRM Steps:  Navigate to  https://make.powerapps.com Cli...