locked
how to apply custom filter for crmGrid? RRS feed

  • Question

  • Hello 

    there is customer filter with Date From,Date To, and Customer Name fields in the custom filter. 

    but how to apply these conditions to reload crmGrid. 

     

    i just found one method : crmGrid.Refresh(). but i cannot inject my conditions. 

    please advise. 

     

    any ideas will be appreciated.

    Tuesday, January 18, 2011 7:42 AM

Answers

All replies

  • You can create an html page and put it in ISV. Path would be OnLoad like :-

    if ((crmForm.all.new_companyname.DataValue != null) && (crmForm.all.new_telephonenumber.DataValue == null)) {
            var urla = "/ISV/Iframes/Account/AccountNameFF4.html";
            crmForm.all.IFRAME_Account.src = urla;
        }

    Html Page is as under. You can change the fetch xml and column names according to you requirement:-

    <html>
    <head>
    <script type="text/javascript">
      //alert("Hi"); 
    var oTelephone = parent.document.forms[0].all.new_telephonenumber.DataValue;
    if (oTelephone != null)
    {
    
    var fetchBusinessNo = '<condition attribute="telephone1" operator="eq" value="';
    fetchBusinessNo +=oTelephone;
    fetchBusinessNo += '"/>';
    
    var fetchHomeNo = '<condition attribute="telephone2" operator="eq" value="';
    fetchHomeNo +=oTelephone;
    fetchHomeNo += '"/>';
    fetchPhone = fetchBusinessNo+fetchHomeNo;
    //alert(fetchPhone);
    }
    var oFetch = fetchPhone;
    function getFetchXML()
    {
      var strXML = '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false"><entity name="account"><attribute name="name"/><order attribute="name" descending="false"/><filter type="or">'+oFetch+'</filter></entity></fetch>';
    //alert(strXML);  
    return strXML;
    }
    </script>
    
    <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
    </head> 
    
    <body onload="document.getElementById('fetchinput').value = getFetchXML();resultRender.submit();">
        <FORM id=resultRender action="http://<CrmServer>/<OrgName>/AdvancedFind/fetchData.aspx" method="post"><INPUT type="hidden" name="FetchXml" id="fetchinput" value='' /><INPUT value='<grid name="resultset" object="1" jump="name" select="1" icon="1" preview="1"><row name="result" id="accountid"><cell name="name" width="200"/><cell name="primarycontactid" width="110"/><cell name="telephone1" width="80"/><cell name="telephone2" width="90"/></row></grid>' type=hidden name=LayoutXml> <INPUT value=account type=hidden name=EntityName> <INPUT value={00000000-0000-0000-00AA-000000666000} type=hidden name=DefaultAdvFindViewId> <INPUT value={00000000-0000-0000-00AA-000000666000} type=hidden name=ViewId> <INPUT value=1039 type=hidden name=ViewType> <INPUT value=name type=hidden name=SortCol> <INPUT value=false type=hidden name=SortDescend>  
        </FORM>
      </body>
    </html>
    You can make multi pages and call them according to your requirement.
    Regards Faisal
    Tuesday, January 18, 2011 9:36 AM
  • Hello 

     

    thank you very much. 
    your way is working. but that's not i want. 

    we need to inject some parameters into "crmGrid", not use AdvancedFind way. 

     

    so ,for example: 

    there is a entity Contacts , after you clicked button "Contacts" on the left navigation, all contacts will be listed on the right area. 

    now, i want to filter current list, but not use QuickFind search box. 

    if i want to search "Full Name contains Daniel, and email = xx@aa.com ", how to "inject" these parameters?

    current crmGrid has Refresh funtion (crmGrid.Refresh();). but i cannot inject parameters ,

     

    i hope there is a function such like : 

    crmGrid.setParameter('FullName','Daniel');

    crmGrid.setParameter('email','xx@aa.com');

    crmGrid.Rebind();

     

    are there such functions? 

     

    Thank you

     

     

    Thursday, January 20, 2011 8:19 AM
  • if the following solve your problem than I can send you the code:-

    http://marcoamoedo.com/blog/creating-a-multi-field-search-screen-in-dynamics-crm/

     


    Regards Faisal
    Thursday, January 20, 2011 9:49 AM
  • Hi, use crmGrid.Reset(); on replace of crmGrid.Rebind();
    Nitin Pawar
    Tuesday, November 8, 2011 6:27 AM
  • Hi Faisal

    Is it possible you could send me the code for this?

    Regards
    Andy

    Monday, November 14, 2011 9:15 AM
  • Hi Faisal,

    Can you send me the code as you proposed in your answer?

    Thx,

    Ercan

    Monday, February 27, 2012 4:21 PM