Trigger a Power Automate Flow only if a specific user modified a SharePoint list item

If you want to proceed running actions in a Power Automate Flow only if a specific user did the change in a SharePoint list item, you can easily use a condition and manage that. But this will consume one Flow run from your daily runs allowance.

To do this before the Flow is executed, you can use Trigger conditions to achieve it. So the Flow will be triggered only if the formula specified as condition returns true.

How to do it?

To add trigger conditions, click the Settings button for your flow Trigger (in our case the SharePoint trigger ‘When an item is created or modified’.

Capture0

Then add a new condition with the following formula (replace the email address to your e-mail address in lowercase):

@equals(toLower(triggerBody()?[‘Editor’]?[‘Email’]),’user@domain.com’)

Capture

I’m using toLower here to avoid any mess related to character case (like user being User.Surname@domain.com instead of user.surname@domain.com). The syntax for the formula is the same for expressions inside a flow, the difference is that it should be preceded by @.

Also, I’m using the ‘Editor’ field to do the check based on who modified the item (will be the same as ‘Author’ for a new item). In case you want to check who created the item instead, use the ‘Author’ field.

The same approach can be used for the following SharePoint triggers in Power Automate too:

  • When an item is created
  • When a file is created (properties only)
  • When a file is created or modified (properties only)

To validate the behaviour, add any action to the flow like I’ve added below, and save it:

Capture4
Results

If you add or modify items with the user that was specified in the formula, the Flow is going to be normally triggered, as shown in the flow history.

Captureab

But if changes are done by someone else, the runs are skipped and nothing happens.

You can check the skipped runs from the flow history under the option ‘All Runs’:

Captureabc
And the view ‘Checks (no new data)’:

Captureabcd

Note that all checks done when an item is modified by a user that is not the one specified are marked as skipped.

By a simple tweak in the Flow trigger settings, it’s possible to avoid unnecessary flow run consumption from your user runs quota.

11 comments

  1. Hey Michel,
    I have a flow that should trigger when an item is added to a list (a survey actually). The flow triggers and runs normally when I add an item to the list, but it does not run/trigger when others enter an item. Note that it’s not like when other people enter an item, the flow fails, instead, the flow never even runs.
    Not sure if this matters but this survey setting is set so that users can only see/edit their own response.
    Any thoughts? Thank you.

    1. Hi Dan,
      What is the permission level for your account on this list? Just collaborate?

      If you enable this setting to allow people to see/edit only their own response, and the account you used in the Flow has just collaborate permissions on the list, the Flow won’t be triggered.

      The person needs to have Edit permissions on the list or at least a custom permission level with ‘Override List Behaviours’ added (which allows you to see/edit others people’s responses added) for the flow to be triggered. As Flows run under a user account, it can’t detect new items that this account doesn’t have permissions to read.

      1. Michel, thanks for the quick response.
        My account has full control of the list. I also made 2 other individuals Owners of the flow. They too have full control of the list/survey.

      2. No worries….
        Isn’t there any Flow trigger condition? Is the account used in the Flow trigger one of the accounts with full control permissions?
        It should work if you all have full control. If the user has full control by consequence the ‘Override List Behaviours’ is granted.

    1. Hi Michel,
      I am getting the folloowing error when I am trying to save the flow:

      The template language expression ‘equals(toLower(triggerBody()?[‘Editor’]?[‘Email’]),’user@domain.com’)’ is not valid: the string character ‘‘’ at position ’30’ is not expected.

      the difference I see is that I am using

      @triggerOutputs()?[#body/value’]

      as the array. Do I need to modify the trigger somehow?

      1. Hey Daniel,

        I could replicate the behaviour using your format, you have to use an expression that returns a boolean so the trigger fires when true or is ignored when false.
        See example below:
        @equals(toLower(triggerOutputs()?[‘body/Editor/Email’]),’user@domain.com’)

        If you want to send the exact comparison you are trying I may be able to help better.

  2. How do you achieve multiple conditions with formula? Send an email if a new item is created or modified and the status equals Pending (if new item status is Pending or if modified item status is Pending then send an email)
    @equals(toLower(triggerBody()?[‘Author’]?[‘Email’]),’user@domain.com’), equals(toLower(triggerBody()?[‘Editor’]?[‘Email’]),’user@domain.com’)

    1. Hi Stephanie,

      You can use the ‘or’ and ‘and’ operators around the formulas, in groups of two conditions…like:
      or(condition1,condition2)
      and(condition1,condition2)
      And you can nest multiple conditions…

      For example if you want to check first if the author or editor are a person and considering a choice field with internal name as ‘Status’ as the one you are picking the status, you can use:
      @and(or(equals(toLower(triggerBody()?[‘Editor’]?[‘Email’]),’user@yourdomain.com’),equals(toLower(triggerBody()?[‘Author’]?[‘Email’]),’user@yourdomain.com’)), equals(triggerBody()?[‘Status’]?[‘Value’],’Pending’))

      Let me know if that helps 😀

  3. Hi, I am trying to use this but when I apply the logic I get a Null retrun inside the ToLower command, it is as iff the Editor is not inside the body. Is there a place I need to set this

    1. Does your user have the email property configured in O365 and what exact trigger you are using?
      Send me how are you writing your trigger condition (copy and paste in the comment) so I may be able to help…

Leave a Reply

Your email address will not be published. Required fields are marked *