Retrieve Lookup view query filters in CRM 2011

Answered Retrieve Lookup view query filters in CRM 2011

  • Friday, June 08, 2012 2:47 PM
     
      Has Code

    Hello, 

    I'm trying to retrieve all metadata information for a given build-in lookup view (for example: contact lookup view). I'm able to retrieve LayoutXml and FetchXml from SavedQuery table but I can't find a way to retrieve the search criteria.

    <!--LayoutXml-->
    <grid name="resultset" object="2" jump="fullname" select="1" preview="0" icon="1">
      <row name="result" id="contactid">
        <cell name="fullname" width="300" />
        <cell name="parentcustomerid" width="150" />
        <cell name="address1_city" width="100" />
        <cell name="address1_telephone1" width="125" />
        <cell name="telephone1" width="125" />
        <cell name="emailaddress1" width="200" />
        <cell name="pa_chapterterritorycode" width="100" />
        <cell name="pa_chapterterritoryid" width="100" />
        <cell name="fax" ishidden="1" width="100" />
        <cell name="address1_name" ishidden="1" width="100" />
        <cell name="address1_fax" ishidden="1" width="100" />
      </row>
    </grid>
    <!--FetchXml-->
    <fetch distinct="false" mapping="logical">
      <entity name="contact">
        <attribute name="fullname" />
        <attribute name="parentcustomerid" />
        <attribute name="address1_city" />
        <attribute name="address1_telephone1" />
        <attribute name="telephone1" />
        <attribute name="emailaddress1" />
        <attribute name="contactid" />
        <attribute name="fax" />
        <attribute name="address1_name" />
        <attribute name="address1_fax" />
        <attribute name="pa_chapterterritorycode" />
        <attribute name="pa_chapterterritoryid" />
        <filter type="and">
          <condition attribute="statecode" operator="eq" value="0" />
        </filter>
        <order attribute="fullname" descending="false" />
      </entity>
    </fetch>

    When you open a Lookup view on CRM 2011 you can use a textbox to filter the resultset. What I want to know is how the value of that textbox is used, which columns are filtered, etc. AFAIK you cant't extract that information from the above XMLs (CRM 2011 seems to filter fullname and emailaddress1, but no telephone1, address1_city or fax).

    Any help would be very appreciated. Thanks in advance

All Replies

  • Friday, June 08, 2012 6:57 PM
     
     Answered

    The columns filtered in the lookup dialog are the same as the columns filtered for quick find view.

    The behaviour of the Search textbox in the lookup dialog is the same as the textbox for quick find view.

    Whatever Find Columns which are added in the Quick Find view will also affect the search columns in the lookup dialog.

    But I don't think you are able to define those search columns explicitly in your custom filtered lookup by modifying the XML values.

    • Marked As Answer by Tincho.NET Wednesday, June 13, 2012 1:30 PM
    •  
  • Wednesday, June 13, 2012 1:29 PM
     
      Has Code

    Thank you Linn, that is what I was looking for.

    Now I can extract filter criteria from the Quick Find record and merge it with Lookup's fetch xml. The result is something like this:

    <fetch distinct="false" mapping="logical">
      <entity name="contact">
        <attribute name="fullname" />
        <attribute name="parentcustomerid" />
        <attribute name="address1_city" />
        <attribute name="address1_telephone1" />
        <attribute name="telephone1" />
        <attribute name="emailaddress1" />
        <attribute name="contactid" />
        <attribute name="fax" />
        <attribute name="address1_name" />
        <attribute name="address1_fax" />
        <attribute name="pa_chapterterritorycode" />
        <attribute name="pa_chapterterritoryid" />
        <filter type="and">
          <condition attribute="statecode" operator="eq" value="0" />
        </filter>
        <filter type="or">
          <condition attribute="middlename" operator="like" value="{0}" />
          <condition attribute="lastname" operator="like" value="{0}" />
          <condition attribute="fullname" operator="like" value="{0}" />
          <condition attribute="firstname" operator="like" value="{0}" />
          <condition attribute="emailaddress1" operator="like" value="{0}" />
          <condition attribute="pa_contactnumber" operator="like" value="{0}" />
        </filter>
        <order attribute="fullname" descending="false" />
      </entity>
    </fetch>
    Thanks again

  • Wednesday, June 13, 2012 1:57 PM
     
     
    Thanks for posting your solution. I didn't know that we can use the condition with value="{0}" and now I also learn a new thing.