cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Community Support
Community Support

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.
Highlighted
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?

Highlighted
Community Support
Community Support

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

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 (7,122)