locked
Pass Multiple Guid in Fetch XML RRS feed

  • Question

  • Can you please send sample code to fetch multiple record value in a single fetch xml

    e g : i have list of five users owner id and i need to pass all the user id , and i need to fetch record .

    i am not familiar , how to pass multiple filter condition at run time.

    eg :  

    <fetch>
    <entity name="account">
     <attribute name="accountname" alias="AccountName" />
     <attribute name="accountnumber" alias="AccountNumber" />
     <filter>
      <condition attribute="ownerid" operator="in" value="@owner" />

      <condition attribute="ownerid" operator="in" value="@owner" />
     </filter>
    </entity>
    </fetch>

    Monday, November 25, 2013 2:44 PM

All replies

  • Hello,

    Use advanced find to create fetchXML queries.

    Here is the query created from advanced find :

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
      <entity name="account">
        <attribute name="name" />
        <attribute name="accountid" />
        <order attribute="name" descending="false" />
        <filter type="and">
          <condition attribute="ownerid" operator="in">
            <value uiname="CRM Admin1" uitype="systemuser">{2A4F3405-CA4D-E311-92CD-D89D676E8210}</value>
            <value uiname="CRM Admin2" uitype="systemuser">{A0087026-CA4D-E311-8E60-D89D6779D5EC}</value>
            <value uiname="CRM Admin3" uitype="systemuser">{C8A7B7FF-D505-420B-9C03-ADD331253583}</value>
          </condition>
        </filter>
      </entity>
    </fetch>

    Or try this one :

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
      <entity name="account">
        <attribute name="name" />
        <attribute name="accountid" />
        <order attribute="name" descending="false" />
        <filter type="and">
          <condition attribute="ownerid" operator="in">
            <value >{2A4F3405-CA4D-E311-92CD-D89D676E8210}</value>
            <value >{A0087026-CA4D-E311-8E60-D89D6779D5EC}</value>
            <value >{C8A7B7FF-D505-420B-9C03-ADD331253583}</value>
          </condition>
        </filter>
      </entity>
    </fetch>


    Hope this helps. If you get answer of your question, please mark the response as an answer and vote as helpful !!!
    Vikram Singh. !!!  My Blog


    Monday, November 25, 2013 3:06 PM
  • search for a tool called "fetchxml builder", it is a simple tool that helped me to learn fetchxml.

    Tuesday, November 26, 2013 12:47 AM