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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

error "entity doesn't contain attribute with Name ..." from CDS Odata query

(0) ShareShare
ReportReport
Posted on by 37

Hi,

I am using some custom entities in common data services, let's call them "parent" and "child", where there is a one-to-many relationship between them. I'm trying to count how many children each parent has, and as far as I can tell from the documentation here https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/query-data-web-api#aggregate-and-grouping-results I should be doing something like:

GET api/data/v9.0/children?$apply=groupby((parent/parentid), aggregate(parentid with countdistinct as total))

but I get an error:

'child' entity doesn't contain attribute with Name = 'parent' and NameMapping = 'Platform'".

Even if I take off the aggregation clause like this:

GET api/data/v9.0/children?$apply=groupby((parent/parentid))

the error message is the same.

If I replace either the word "parent" or "parentid" with gobbledygook I get a different and sensible error message so I know I'm putting in the correct names

Also if I do this:

GET api/data/v9.0/children?$filter=(parent/parentid eq 'xxxx-xxxxxx-xxxx')

then I get the result I'd expect, so it shows I can follow the child->parent relationship inside the filter but seemingly not inside the apply.

I've searched on the forums for that error message and most of the occurrences seemed to be down to server-side caching but I'm using Dynamics 365 online so there's nothing I can do about that.

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    There is a chance that CDS version of WebApi doesn't implement your particular scenario. If you want to make it work my recommendation - try to use FetchXml and aggregation inside of it to make it work - docs.microsoft.com/.../retrieve-and-execute-predefined-queries

  • Pankaj Gogoi Profile Picture
    3,177 on at

    Hello Tim,

    I would suggest you create a Text field and store the primary key of the parent entity and then use this text field to group by.

    I got the same message when retrieving list of contacts by Account and was able to fetch the count based on text field.

    Best Regards

    PG

  • Tim Robinson Profile Picture
    37 on at

    Thanks @Andrew and @Pankaj G for the suggestions for workarounds.

    On further investigation It turns out my immediate requirement is actually only to find out whether there are any children, not necessarily to count them, so I'm using something like "GET parent?$filter=children/any()" which works OK, so I'm using that in a second query to retrieve a list of parent ids of those parents that have children, then match the main results against that list.

    Because my app is nearly complete and the rest of it works fine with OData querties, I'm reluctant to start using FetchXml but I'll consider it if I hit ODATA issues I can't resolve in the future.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 96 Super User 2025 Season 2

#2
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans