0

I am trying to update manager's name and unable to find the condition to stop the infinite loop it goes into.

Here is the background on the issue: Sharepoint to Sharepoint - Power Flow: How to update "manager's name" based on user's name in the *same* item when item is created or modified?

My trigger is when item is created or updated and it stop with updating item but that is again taken as a trigger to update. How do I break it?

Here are the screenshots of what I am trying to achieve.

enter image description here

enter image description here

2 Answers 2

1

Please following steps:

Solution A:

1.Add column to your list. For example, add [Status] (Choice column) and set default value is Pending.

enter image description here

2.In order to avoid endless loops, you can set conditions: update item when [Status] is Pending, and change [Status] to Completed. Then it will jump out of the next cycle.

enter image description here

Solution B:

Add Condition action to the Microsoft Flow:

  • Manager's Name Claims is equal to null

Or

  • Manager's Name Claims is not equal Display Name

enter image description here

======================= Updated Answer ========================

In My Testing:

1.Create new item:

enter image description here

2.Microsoft Flow

enter image description here

3.Result

enter image description here

======================= Updated Answer ========================

Get user profile (V2) User (UPN): Engineer's Name Email

enter image description here

Condition: Manager's Name DisplayName is not equal to Display Name

enter image description here

The Flow will be triggered twice, because as long as the value of the item is modified, the flow will be triggered. However, if the Manager's Name Displayname is equal to the Get manager Display name, the item will not be updated and break out of the loop.

7
  • just tested "Manager's Name Claims is not equal Display Name" approach. still the same issue. if you look at the history of "All runs" the condition evaluates to False. still not sure how to fix it. Did it work for you?
    – SunMan
    Aug 26, 2021 at 12:03
  • Hi SunMan. Yes, it works in my test. I have updated my Answer. Hope this helps you. Aug 27, 2021 at 4:11
  • Thanks EchoDu. I noticed your screenshot is not correct. Parameter for UPN has to be "User principal name or email id"
    – SunMan
    Aug 27, 2021 at 18:14
  • Condition's screenshot is incorrect too. It should be item's display name i.e. Manager's Name DisplayName __ isNotEqualTo __ DisplayName. This stops it going in the loop. Could you verify and correct your screenshot and I'll accept your answer? Thanks for all the testing. You have been the most helpful person for both of my issues.
    – SunMan
    Aug 27, 2021 at 18:35
  • Another issue I would love to solve is to make it run only once. Currently it runs twice. It should not run when updated by the flow itself... may be a DCR/feature request...lol.
    – SunMan
    Aug 27, 2021 at 18:42
0

To break the loop, use a Power Automate (PA) Trigger Condition. Please refer to this link for details.

Here are the steps that I would use to break the loop in PA:

  1. Add a [Status] column to your list with a default value Pending. When the PA is triggered for the first time and the corresponding item is updated (Manager's name, in this case), update the [Status] column's value as well to something like Updated.

  2. Set the Trigger Condition in PA. The expression would be like ([Status] is a Choice Type Column in the example)

@equals(triggerBody()?['Status']?['Value'], 'Pending')

  1. The PA should only trigger when the [Status]='Pending'
5
  • There is one problem with this approach. the user may update "Engineer's Name" without updating the new "Status" field.
    – SunMan
    Aug 26, 2021 at 11:24
  • User doesn't have to update this field.. it can be hidden to the end user in the view. It's kind of system field and needs to be updated in the Power Automate, not by the end user Aug 26, 2021 at 12:25
  • Day 1 ======== Step 1 - Day 1, User fills only Engineer's Name Engineer's Name = Matiur Manager's Name = Status = Pending (default value on the column) Step 2 - flow triggers (b'coz item got created) Step 3 - Gets item's fields Step 4 - Checks condition. Is Status = Pending ? Step 5 - Condition is True so update items to below Engineer's Name = Matiur Manager's Name = Donald Trump Status = Updated Step 6 - flow triggers (b'coz item got updated) Step 7 - Gets item's fields Step 8 - Checks condition. Is Status = Pending ? Step 9 - Condition is False. No need to update.
    – SunMan
    Aug 26, 2021 at 12:49
  • Day 2 ======== Step 1 - The next day, User updates only Engineer's Name Engineer's Name = Robin Manager's Name = Donald Trump Status = Updated Step 2 - flow triggers (b'coz item got updated) Step 3 - Gets item's fields Step 4 - Checks condition. Is Status = Pending ? Step 5 - Condition is False. No need to update. .....> Impact: Robin's manager can be "Joe Biden" not "Donald Trump" but item is not updating any more.
    – SunMan
    Aug 26, 2021 at 12:49
  • Yeah, it's based on your requirements you need to work on the Trigger Condition of PA, which is the main issue in your post Aug 26, 2021 at 14:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.