locked
filtering subject RRS feed

  • Question

  • Hi, i have seen ways to filter on lookup that uses the crmgrid via fetchxml and lookupsingle.aspx. Can we do something similar to the subject tree? that AppTree in lookupsubject.aspx? Many thanks, Kenneth
    Wednesday, November 4, 2009 2:53 AM

Answers

  • You could always write your own crm subject lookup form and hide the original button, then put your own button after it.  I use an onload event to hide the core crm button and append a new button that looks just like the old one, but launches my own custom form.  The problem with that is the form assistant.  Here is my code that I use to change the button to my custom button.  This might give you an idea of how to do it.

    function CustomLookup(lookup, org, type, allowsort, values) {
        var url = "/CustomLookup/lookupsingle.aspx?config=" + type + "&org=" + org;
        if (!allowsort) url += "&allowsort=false";
        if (values != null && values != undefined && values.length > 0) url += "&values=" + values;
    
        var wstatement = "var retval = window.showModalDialog('" + url + "',null,'dialogWidth:600px; dialogHeight:400px; center:yes');" +
    	                 "if (retval==null) {return; } " +
    	                 "else { " + lookup + ".DataValue" + " = retval;} ";
    
        return wstatement
    }
    
    function CreateCustomLookup(id, org, type, allowsort, values) {
        var nb = document.getElementById(id + "_custom");
        if (nb != null && nb != undefined) {
            var p = nb.parentNode;
            p.removeChild(p.lastChild);
        }
    
        var button = document.getElementById(id);
        button.style.display = "none";
        var title = button.getAttribute('title');
    
        var onimage = '/_imgs/btn_on_lookup.gif';
        var offimage = '/_imgs/btn_off_lookup.gif';
    
        var image = "<IMG style=\"cursor:hand\" id=\"" + id + "_custom\"" +
                    " alt=\"" + title + "\" title=\"" + title + "\" src=\"" + offimage + "\" " +
    				"onmouseover=\"document.getElementById('" + id + "_custom').src='" + onimage + "';\" " +
    				"onmouseout=\"document.getElementById('" + id + "_custom').src='" + offimage + "';\" " +
    				"onclick=\"" +
    				CustomLookup("crmForm.all." + id, org, type, allowsort, values) +
    				"\" />";
    
        var imageElement = document.createElement(image);
        button.parentNode.appendChild(imageElement);
    }


    --MSCRM Blogger.
    Thursday, November 5, 2009 12:35 PM