Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Aggregate FetchXML against WebAPI fails

Posted on by

Hi,

The following fetchXml works fine against OrgSvc:

<fetch top='50' aggregate='true' >
  <entity name='account' >
    <attribute name='cf_customerclassification' alias='classification' groupby='true' />
    <attribute name='cf_segment' alias='segment' groupby='true' />
    <link-entity name='peikko_memo' from='peikko_account' to='accountid' link-type='inner' alias='account' >
      <attribute name='peikko_date' alias='quarter' groupby='true' dategrouping='quarter' />
      <attribute name='createdon' alias='cnt' aggregate='count' />
      <filter>
        <condition attribute='ownerid' operator='eq' value='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' />
        <condition attribute='peikko_date' operator='in-fiscal-year' value='2017' />
      </filter>
    </link-entity>
  </entity>
</fetch>


I'm porting all the scripts to use WebAPI instead of REST+SOAP. When the same fetchxml is executed against WebAPI, I get this error message:

The property provided was of type System.Int32, when the expected was of type System.DateTime

Anyone had the same problem?

Thank you,
Laszlo

*This post is locked for comments

  • Stefan Hallberg Profile Picture
    Stefan Hallberg 10 on at
    RE: Aggregate FetchXML against WebAPI fails

    Thanks for the info Laszlo

  • Suggested answer
    LaszloPenzes Profile Picture
    LaszloPenzes on at
    RE: Aggregate FetchXML against WebAPI fails

    Hi Stefan!

    I'm also still experiencing the same issue at multiple customers, in online envs. I have a support ticket open @MS, they said that the fix has been scheduled for 2nd week of Nov. Will probably be rolled out in the next update after that.

    Cheers,

    Laszlo

  • Stefan Hallberg Profile Picture
    Stefan Hallberg 10 on at
    RE: Aggregate FetchXML against WebAPI fails

    Hi Laszlo, I'm still hitting this issue with REST api. It's onprem version 9.0.21.8

  • RE: Aggregate FetchXML against WebAPI fails

    Thanks for the additional information!  I have been able to repro in house, but please note the issue has been fixed in the latest Dynamics 365 version (9.0*).  We will evaluate what it would take to enable this in the 8.2 version.

  • LaszloPenzes Profile Picture
    LaszloPenzes on at
    RE: Aggregate FetchXML against WebAPI fails

    Hi Brandon,

    First of all: thank you for looking into the problem!

    I could still reproduce on a 8.2 online environment with this fetchxml:

    <fetch top='50' aggregate='true'>
      <entity name="account">
        <attribute name="industrycode" alias='industrycodes' groupby='true'/>
        <attribute name="accountratingcode" alias='ratingcodes' groupby='true'/>
        <link-entity name="contact" from="contactid" to="primarycontactid" link-type="inner" alias="thecontact">
          <attribute name="modifiedon" alias='quarter' groupby='true' dategrouping='quarter'/>
          <attribute name="createdon" alias='cnt' aggregate='count'/>
          <filter>
            <condition attribute="modifiedon" operator="in-fiscal-year" value="2018" />
          </filter>
        </link-entity>
      </entity>
    </fetch>

    The difference is that the attribute causing the problem has to appear as

    • attribute of link-entity, marked with groupby='true' and dategrouping='quarter'
    • filter condition, marked with in-fiscal-year

    In your example two different fields were referenced:

          <attribute name="modifiedon" alias='quarter' groupby='true' dategrouping='quarter'/>

          <attribute name="createdon" alias='cnt' aggregate='count'/>

          <filter type="and">

            <condition attribute="ownerid" operator="eq" uiname="Brandon Simons" uitype="systemuser" value="{278742B0-1E61-4FB5-84EF-C7DE308C19E2}" />

            <condition attribute="createdon" operator="in-fiscal-year" value="2017" />

          </filter>

    BR,

    Laszlo

  • RE: Aggregate FetchXML against WebAPI fails

    Hello - 

    Are folks still hitting this issue?  I have tried to create a repro, but haven't been able to get the error.  Here is an example of what I am using (trying to use out-of-box schema as I don't have custom schema).

    <fetch top='50' aggregate='true' version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
      <entity name="account">
        <attribute name="industrycode" alias='industrycodes' groupby='true'/>
        <attribute name="accountratingcode" alias='ratingcodes' groupby='true'/>
        <link-entity name="contact" from="contactid" to="primarycontactid" link-type="inner" alias="thecontact">
          <attribute name="modifiedon" alias='quarter' groupby='true' dategrouping='quarter'/>
          <attribute name="createdon" alias='cnt' aggregate='count'/>
          <filter type="and">
            <condition attribute="ownerid" operator="eq" uiname="Brandon Simons" uitype="systemuser" value="{278742B0-1E61-4FB5-84EF-C7DE308C19E2}" />
            <condition attribute="createdon" operator="in-fiscal-year" value="2017" />
          </filter>
        </link-entity>
      </entity>
    </fetch>

    -Brandon

    MS Product Team

  • LaszloPenzes Profile Picture
    LaszloPenzes on at
    RE: Aggregate FetchXML against WebAPI fails

    I met the MS Program Manager in Dubrovnik @eXtreme365, he forwarded the problem to his  colleagues.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Aggregate FetchXML against WebAPI fails

    On Premise

  • Daryl LaBar Profile Picture
    Daryl LaBar 500 Most Valuable Professional on at
    RE: Aggregate FetchXML against WebAPI fails

    @dynamicWrittern, If you're online, you'll need to have an Office 365 admin to submit it.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Aggregate FetchXML against WebAPI fails

    @Daryl LaBar how do I submit a ticket with MS?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans