cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Patron
Post Patron

Count number of related CDS records

I have two custom entities in my CDS. One entity is Tracker, the other entity is Details. Details has a many to one relationship with Tracker. 

 

Tracker has a lookup named Facility(cr5be_facility), that does a lookup to the Facility Entity to pull the Facility name the tracker is about. 

 

Details has a lookup to Tracker, also named Facility(cr5be_facility), that does a lookup to the Tracker entity to pull the name the details are about.

 

I'm trying to create a flow, that when a new record is added to the Details entity, a field on the Tracker record it's connected to will be updated with a count of the number of records in the Details. This count should be based on an option set field on the Details record named Survey Outcome(cr5be_surveyoutcome).

 

So, for each choice in Survey Outcome on the Details record, I intend to have a count of the number of those Outcomes, on the related record in the Tracker entity. 

 

Hopefully I explained that clear enough someone can understand what I mean. 

 

I've tried to do a Flow that would compare the Facility fields, but it did not work. I assume it's because one of the Facility fields is a lookup to the Facility entity, where the other lookup is to the Tracker. While they have the same text value, it seems like the GUID is what's actually getting compared; which of course is different.

 

2020-01-28 14_33_22-Edit your flow _ Power Automate.png 

4 REPLIES 4
Highlighted
Super User
Super User

Re: Count number of related CDS records

Hello,

For lookup fields reference. Check out my solution on this post:
https://powerusers.microsoft.com/t5/General-Power-Automate/Filter-Query-in-List-Records-not-working-...

Note that in my example I am using Dynamics 364 connector. The same will be applied with the CDS connector.

If this does not help you, could you try and give some additional information.

--Josh

If you like my post please hit the "Thumbs Up" -- If my post solved your issue please "Mark as a Solution" to help others




Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up ?


Proud to be a Flownaut!





Highlighted
Community Support
Community Support

Re: Count number of related CDS records

Hi @notj ,

 

The expression to count the number of the records:

length(body('List_records')?['value'])

 

1.png

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Highlighted
Post Patron
Post Patron

Re: Count number of related CDS records

@Jcook I'll give that a look, thanks.

 

@v-alzhan-msft I don't think you understand what the issue is. It's not "how am I going to count them". It's the relational part.  Basically, all the stuff I described in the post.

 

 

Highlighted
Post Patron
Post Patron

Re: Count number of related CDS records

@Jcook Unfortunately, I was right. While the labels are the same, the values are not. Both fields are named Facility, both are lookups, but one is on the parent (Trackers) entity, and the other is on another entity (All Facilities). So the GUID's don't match.

 

Is there any way to compare the displayed text values instead of the GUID?

Helpful resources

Announcements
firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Users online (6,974)