Monday 25 February 2019

Show only Account or Contact in customer lookup dynamic 365


To show only account or contact in customer lookup, follow the below steps

1) On Load of form add the following code

if (Xrm.Page.getControl("customerid") != null) {
            Xrm.Page.getControl("customerid").addPreSearch(function () {
                filterCustomerLookup ();
            });
        }

2)Register this function on OnChange event of customer lookup to show only account in customer lookup

    function filterCustomerLookup () {

        var lookup = Xrm.Page.getControl('customerid');

        //check if multiple type dropdowns enabled for this lookup
        if (lookup.getEntityTypes().length > 1) {
            lookup.setEntityTypes(['account']);
        }

        var fetchXml = "<filter type='and'>";
        fetchXml += "<condition attribute='statecode' operator='eq' value='0'/>";
        fetchXml += "</filter>";

        if (Xrm.Page.getAttribute("customerid") != null) {
            Xrm.Page.getControl("customerid").addCustomFilter(fetchXml, "account");
        }
    }



To show only contact  then change account to contact.

function filterCustomerLookup () {

        var lookup = Xrm.Page.getControl('customerid');

        //check if multiple type dropdowns enabled for this lookup
        if (lookup.getEntityTypes().length > 1) {
            lookup.setEntityTypes(['account']);
        }

        var fetchXml = "<filter type='and'>";
        fetchXml += "<condition attribute='statecode' operator='eq' value='0'/>";
        fetchXml += "</filter>";

        if (Xrm.Page.getAttribute("customerid") != null) {
            Xrm.Page.getControl("customerid").addCustomFilter(fetchXml, "contact");
        }
    }


Numbering Table Parent group and child group ssrs report

 Recently I have faced a scenario to numbering parent group and subgroup in the following formate 10 parentGroupRow1    10.1 childGroupRow1 ...