cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TomGothard1992
New Member

Adding 1 to an existing field once the flow has run

Hi,

 

I would like to be able to +1 to a value in an existing field once the flow has run so I can prevent it from looping everytime it's modified but I can't figure out the expression. It's probably very simple but I'm just going in circles at the moment so any help would be greatly appreciated!

 

Thanks!

6 REPLIES 6
v-yuazh-msft
Community Support
Community Support

Hi @ TomGothard1992,

 

Could you please share a screenshot of the configuration of your flow?

Could you please share more details about the value in an existing field that you want to add 1? Does the existing field is a field in your sharepoint list?

If the existing field is a field in your sharepoint list, what is the type of the field in your sharepoint list? Is it a Number type of column?

Could you please explain more about "+1 to a value in an existing field once the flow has run so I can prevent it from looping everytime it's modified" that you mentioned?

 

For you question to add 1 to an existing field, I have made a test on my sideand create a sharepoint list with a number type of column "number".

 

You could create a flow refer to screenshot below to:

Capture.PNG

 

 

The expression in the "numder" field of "Update item" action as below:

add(triggerBody()?['number'],1)
 
You could refer to link below to learn more about the workflow definition language as below:

 

When an item is created or modified, and you could check the value in the number column, if the value in the number column is equal to 0, the flow would add 1 to the value in the number column in the list, the flow would run successfully as below:

Capture.PNG

 

 

 

 

 

Regards,
Alice Zhang

Hi Alice,

 

Thanks for your response it has worked in preventing the flow from looping. The only issue is that (I'm assuming) now it doesn't loop, and therefore fails, it doesn't actually update the original item. Any help would be greatly appreciated.

 

I've attached the images below as I couldn't work out how to screenshot them in here.

 

https://imgur.com/jX8vk4P

 

https://imgur.com/ZtikjGU

 

https://imgur.com/a/eXBzm

 

https://imgur.com/a/AQn8S

Hey @TomGothard1992

 

 

 

You could do a Do Until action that checks whether the Modified action is equal to true.

So something like this:

*Note: You have to use an expression to set the value True. Otherwise it will always return false.

 

See the attachments for screenshots to understand it better.

 

Hope this helps

 

 

Kind regards

 

Tom

 



If this reply has answered your question or solved your issue, please mark this question as answered.

Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up.

Hi, @TomGothard1992

 

Do you want to prevent the start an approval action from run twice when you use the trigger "When an item is created or modified" and you would update the item in the flow?

 

You could take a try to add a choice type column in your sharepoint list named "modified by flow" with to chlice "Yes"and "No", and set the default value to No.

 

When the uer create or update an item in the shrepoint list, he should set the "modified by flow" column to "No".

And in the "Update item" action of the flow, set the "modified by flow" column to "Yes".

 

So you could prevent the start an approval action from run twice by add a condition under the trigger to check if the value of "modified by flow" column is equal to Yes.

If the "modified by flow" column is equal to Yes,do nothing, if the "modified by flow" column isn't equal to Yes, do something you want.

 
 

 

Regards,
Alice Zhang

Hi Alice,

 

I have tried this and whilst it does prevent it from looping, it results in the flow failing and therefore not actually updating the item at all.

 

I'll add some more screenshots, can you advise further or test it at your end?

 

https://imgur.com/dXeCZIA

 

Approval

 

Modified Flow

 

Kind regards,

 

Tom

Hi @TomGothard1992,

 

Could you please share a screenshot of the error when the flow run failed?

Or could you please share more details about the error?

Which action run failed when the flow runs?

 

 

 

Regards,
Alice Zhang

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (19,702)