cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Daily Flow to Update Count

I have two lists: Activity, Claims. For each activity there can be multiple claims tied to it. The Activity list is set up something like this - ID, Title, Claim Count. The Claims list is set up basically like this - ID, ActivityID, Claim Title. Activity.ID=Claims.ActivityID is essentially the common factor.

 

I would like to create a flow that ensures the correct number of claims for each activity. There areroughly 2,000+ claims and 1,700+ activities. Ideally, I was hoping for a flow to run daily that will grab the ID in the Activity List, recount the number of records in the Claims list that have this ActivityID, and update the count if it's different. 

 

How can this be achieved without getting stuck in an infinite loop or messing things up? I'm struggling to find a method that will work. 

 

Thanks in advance

3 REPLIES 3
Community Support Team
Community Support Team

Re: Daily Flow to Update Count

Hi @Anonymous ,

 

What’s the column type of ActivityID? I guess it is a Lookup column.

According to your description, I have created the following tow lists for testing.

Activity list: ID, Title, ClaimCount (type of number)

Claim list: ID, Title, ActivityID (Lookup to ID of Activity list)

Then I started the flow with a button trigger. You may change it to a Recurrence button so that it could run daily.

Get items from Activity.

Then get items from Claims. Add action Get items 2, input the following code in Filter Query field:

ActivityID eq ‘ID’

Note: ID is dynamic content from action Get items, make sure surround it with a single quote. At here, an Apply to each will be added automatically.

Add a Compose action with the following code:

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

Add action Update item to update ClaimCount field in Activity list. Select dynamic content ID, Title from Get items, Output of compose action for ClaimCount field.

Image for your reference.

1.PNG

 

Best regards,

Mabel

 

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Re: Daily Flow to Update Count

Thanks @v-yamao-msft - The ActivityID is actually a number field... I created a flow that pushes the ID from the Activity list to the Claims list. When looking at the screenshot of your flow, it's actually very similar to what I currently have. The only difference is the trigger that begins the flow. 

 

I started mine with 'When an Item is created or modified' in the Activity list. My flow ended with 'Update Item' in the Activity list. It was this logic that created my endless loop. My initial thought was to just run this flow everytime an item was added or modified just to double check the count, but I quickly realized that this would result in a loop and cause problems. 

 

I guess all I would need to do is create a reocurrence like you mentioned and mimic your flow, correct?

Community Support Team
Community Support Team

Re: Daily Flow to Update Count

Hi @Anonymous ,

 

The trigger “When an item is created or modified” in this scenario will cause infinite loop.

You could consider changing the trigger to Recurrence so that it could run daily to update count in the Activity list.

 

Best regards,

Mabel

 

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

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 78 members 3,732 guests
Please welcome our newest community members: