web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / Luke Sartain Dynamics / FetchXML – selecting no att...

FetchXML – selecting no attributes gives you all attributes

Luke Sartain Profile Picture Luke Sartain 1,266

I recently encountered a problem with a query inside a scheduled process timing out and the process failing as a result.  The process itself bulk reassigns records based on given criteria, occasionally hitting the 10,000 record mark for each entity.  In order to assign the records we only required the entity reference itself, none of the entity attributes.  As such the query looked similar to the below.  Note the lack of attributes, just a filter.

<fetch>
  <entity name="opportunity" >
    <filter>
      <condition attribute="createdon" operator="last-x-months" value="1" />
    </filter>
  </entity>
</fetch>

As part of the debugging process I copied this query into the FetchXml Builder in the XrmToolBox and to my surprise also encountered a timeout error.  Limiting the query to the top 10

<fetch top="10" >

eventually returned 10 opportunities and all of their attributes.

As this was running against the opportunity it tried to return 250 attributes for 5000 records in each query, thus causing a timeout.  I’m not sure if this has always been the case or just as the result of upgrading to the latest 365 DLLs from the SDK as previously we would use the <all-attributes> tag.

<fetch >
  <entity name="opportunity" >
    <all-attributes/>
    <filter>
      <condition attribute="createdon" operator="last-x-months" value="1" />
    </filter>
  </entity>
</fetch>

Anyway, even if you don’t have use of any of the attributes it seems it would be advised to request at least one to avoid causing unnecessary timeouts.

<fetch top="10" >
  <entity name="opportunity" >
    <attribute name="opportunityid" />
    <filter>
      <condition attribute="createdon" operator="last-x-months" value="1" />
    </filter>
  </entity>
</fetch>

This was originally posted here.

Comments

*This post is locked for comments