locked
How to fetch the attributes based on two different conditions using FetchXML? I want to fetch all the accounts that have availability=2 and 3 from the last retail audit. RRS feed

  • Question

  • <fetch version="1.0" mapping="logical" distinct="true" aggregate="true">
      <entity name="account">
    
    
        <link-entity name="account" from="accountid" to="accountid" link-type="outer" >
          <attribute alias="outlet"  name="name" aggregate="countcolumn" distinct="true"/>
    
          <link-entity name="retailaudit" from="bat_outlet" to="accountid" alias="ak" link-type="inner">
            <link-entity name="retailauditproduct" from="retailaudit" to="retailauditid" alias="al" link-type="inner">
              <filter type="and">
                <condition alias="OOS" attribute="availability" operator="eq" value="2" />
              </filter>
              <link-entity name="product" from="productid" to="productname" alias="am" link-type="inner">
                <filter type="and">
                  <condition attribute="corerange" operator="eq" value="1" />
                </filter>
              </link-entity>
            </link-entity>
          </link-entity>
        </link-entity>
    
        <link-entity name="account" from="accountid" to="accountid" link-type="outer" >
          <attribute alias="outlet2"  name="name" aggregate="countcolumn" distinct="true"/>
    
          <link-entity name="retailaudit" from="outlet" to="accountid" alias="ak2" link-type="inner">
            <link-entity name="retailauditproduct" from="retailaudit" to="retailauditid" alias="al2" link-type="inner">
              <filter type="and">
                <condition alias="OnShelf" attribute="availability" operator="eq" value="2" />
              </filter>
              <link-entity name="product" from="productid" to="productname" alias="am2" link-type="inner">
                <filter type="and">
                  <condition attribute="corerange" operator="eq" value="1" />
                </filter>
              </link-entity>
            </link-entity>
          </link-entity>
        </link-entity>
      </entity>
    </fetch>
    

    Thursday, September 3, 2015 6:15 AM

All replies

  • Hello Megha

    Is this what you are looking for?

    <filter type="or">
                <condition alias="OOS" attribute="availability" operator="eq" value="2" />
       <condition alias="OOS" attribute="availability" operator="eq" value="3" />
              </filter>

    Kind Regards

    Thursday, September 3, 2015 6:47 AM
  • I want to display the result in the chart. A chart which shows the products on x-Axis and on Y-Axis it shows the no of accounts with availability=3 and availability=2 for each product.
    Thursday, September 3, 2015 11:09 AM