Retrieve Lookup view query filters in CRM 2011

Beantwortet Retrieve Lookup view query filters in CRM 2011

  • Freitag, 8. Juni 2012 14:47
     
      Enthält 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

Alle Antworten

  • Freitag, 8. Juni 2012 18:57
     
     Beantwortet

    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.

    • Als Antwort markiert Tincho.NET Mittwoch, 13. Juni 2012 13:30
    •  
  • Mittwoch, 13. Juni 2012 13:29
     
      Enthält 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

  • Mittwoch, 13. Juni 2012 13:57
     
     
    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.