June 24, 2024

Power Automate: SharePoint – When an item is created or modified Trigger

SharePoint list items change a lot, and it’s handy to know when they do. So today, we’ll check the “When an item is created or modified” trigger that helps us to know when changes happen in the list and act on them.

Where to find it?

To find it, you can search for SharePoint “When an item is created or modified” trigger or go to “SharePoint”:

Then select the trigger:

Here’s what it looks like:

Pro Tip:
Power Automate tends to save the most common triggers on the main screen, so check there before going through the full hierarchy. Also, you can use the search to find it quickly.

Let’s look at how to use it.

Usage

The setup is quite simple. You pick your site and list, and Power Automate does all the work. You can also choose a view limiting the columns that SharePoint will return. Limiting lists with many rows and columns makes things a lot faster and easier to manage your Flow.

Please note that the view will only filter the columns and not the rows. If you have filters in the view, they will be ignored

Please note that the “When an item is created or modified” will not trigger deleted items. Instead, you have a separate trigger, “When an item is deleted,” to deal with that.

Outputs

The trigger returns a lot of information in a JSON format, although the conversion from JSON is done automatically for you. Here’s an example:

{
    "headers": {
        "Transfer-Encoding": "chunked",
        "Retry-After": "21600",
        "Vary": "Origin,Accept-Encoding",
        "X-SharePointHealthScore": "1",
        "X-MS-SPConnector": "1",
        "X-SP-SERVERSTATE": "ReadOnly=0",
        "DATASERVICEVERSION": "3.0",
        "SPClientServiceRequestDuration": "175",
        "SPRequestGuid": "ef806fa7-6a4c-4434-883e-ff5466a91761",
        "request-id": "0c60ef00-24f5-11ec-9621-0242ac130002",
        "MS-CV": "<redacted>",
        "Strict-Transport-Security": "max-age=31536000",
        "X-FRAME-OPTIONS": "SAMEORIGIN",
        "Content-Security-Policy": "frame-ancestors 'self' teams.microsoft.com *.teams.microsoft.com *.skype.com *.teams.microsoft.us local.teams.office.com *.powerapps.com *.yammer.com *.officeapps.live.com *.office.com *.stream.azure-test.net *.microsoftstream.com;",
        "MicrosoftSharePointTeamServices": "16.0.0.21722",
        "X-Content-Type-Options": "nosniff",
        "X-MS-InvokeApp": "1; RequireReadOnly",
        "Timing-Allow-Origin": "*",
        "x-ms-apihub-cached-response": "true",
        "Cache-Control": "max-age=0, private",
        "Date": "Mon, 04 Oct 2021 09:24:15 GMT",
        "Location": "<redacted>",
        "P3P": "CP=\"ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI\"",
        "X-AspNet-Version": "4.0.30319",
        "X-Powered-By": "ASP.NET",
        "Content-Type": "application/json; charset=utf-8",
        "Expires": "Sun, 19 Sep 2021 09:24:15 GMT",
        "Last-Modified": "Mon, 04 Oct 2021 09:24:15 GMT",
        "Content-Length": "1808"
    },
    "body": {
        "@odata.etag": "\"1\"",
        "ItemInternalId": "4",
        "ID": 4,
        "Title": "Created",
        "Modified": "2021-10-04T09:24:14Z",
        "Created": "2021-10-04T09:24:14Z",
        "Author": {
            "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
            "Claims": "i:0#.f|membership|manuel@manueltgomes.com",
            "DisplayName": "Manuel Gomes",
            "Email": "manuel@manueltgomes.com",
            "Picture": "https://manueltgomescom.sharepoint.com/sites/Test/_layouts/15/UserPhoto.aspx?Size=L&AccountName=manuel@manueltgomes.com",
            "Department": null,
            "JobTitle": null
        },
        "Author#Claims": "i:0#.f|membership|manuel@manueltgomes.com",
        "Editor": {
            "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
            "Claims": "i:0#.f|membership|manuel@manueltgomes.com",
            "DisplayName": "Manuel Gomes",
            "Email": "manuel@manueltgomes.com",
            "Picture": "https://manueltgomescom.sharepoint.com/sites/Test/_layouts/15/UserPhoto.aspx?Size=L&AccountName=manuel@manueltgomes.com",
            "Department": null,
            "JobTitle": null
        },
        "Editor#Claims": "i:0#.f|membership|manuel@manueltgomes.com",
        "{Identifier}": "Lists%252fCreatedAndModified%252f4_.000",
        "{IsFolder}": false,
        "{Thumbnail}": {
            "Large": null,
            "Medium": null,
            "Small": null
        },
        "{Link}": "<redacted>",
        "{Name}": "Created",
        "{FilenameWithExtension}": "Created",
        "{Path}": "Lists/CreatedAndModified/",
        "{FullPath}": "Lists/CreatedAndModified/4_.000",
        "{HasAttachments}": false,
        "{VersionNumber}": "1.0",
        "{TriggerWindowStartToken}": "<redacter>",
        "{TriggerWindowEndToken}": "<redacted>"
    }
}

A lot is happening here, but we only need to focus on the “body” part. It’s similar to other everyday actions like the “Get items” action. First, we’ll get all columns from the SharePoint list.

SharePoint will return the same results if the item is created or updated.

Since the returns are the same, there’s an easy way to understand if the item was created or updated. Since SharePoint considered the creation of a file as a modification, both dates will be the same. So you can have a “Condition” action that separates both behaviors.

Power Automate will only return the last changes. Suppose you want to understand how to get the previous versions of items in SharePoint lists. In that case, I have a template and a detailed explanation of how to do it in my “How to get previous versions in SharePoint” article.

Limitations

Although Microsoft is quite clear on the behavior, it’s configuring to pick views without filtering the data. The label is clear “Limit Columns by View,” but I think it would be amazing to have a filtered list and only trigger if the elements of that list were updated.

Recommendations

Here are some things to keep in mind.

Always pick from the list.

Always pick the site address and the list name from the list. You’ll be able to define them manually, but doing that has no added value.

Don’t use this for synchronization.

I see many questions regarding synchronization between SharePoint lists, and the “When an item is created or modified “trigger is an excellent target to catch items that need replication. But I would strongly suggest that you not do it. Synchronization of items is an amazingly complex topic in computer science, and we are all super when something doesn’t synchronize properly. If the trigger fails, data will be out of sync, and Power Automate won’t rerun it. If the data is changed on the destination list, you already have a problem that will only worsen over time.

Name it correctly

The name is super important since we can get the trigger from anywhere and with anything. Always build the word so others can understand your use without opening the action and checking the details.

Always add a comment.

Adding a comment will also help to avoid mistakes. Indicate your expectations, why the Flow should be triggered, and the data used. It’s essential to enable faster debugging when something goes wrong.

Back to the Power Automate Trigger Reference.

Photo by Alice Dietrich on Unsplash

Manuel Gomes

I have 18 years of experience in automation, project management, and development. In addition to that, I have been writing for this website for over 3 years now, providing readers with valuable insights and information. I hope my expertise allows me to create compelling, informative content that resonates with the audience.

View all posts by Manuel Gomes →

6 thoughts on “Power Automate: SharePoint – When an item is created or modified Trigger

  1. Hello Manuel,

    I have read that this option in comparing the dates may fail for items that have attachments, because will cause a delay and the dates will be different due to that?

    Thanks,

    Manuel Cordovil

    1. Hi Manuel,

      Yeah, it makes sense but to be honest, I don’t have managed to simulate that. I need to find a better way to compare these dates because a slight difference will invalidate the comparison.

      Cheers

  2. I’ve used this method several time and found it’s not foolproof. If a user saves and new item and clicks save again, SharePoint will create a second version of that item. Then, by the time the Flow triggers, that item will get evaluated as ‘not new’ (created modified). Not all users are ‘trigger happy’, but it does happen.

  3. Hi Manuel, I’ve set up a list on SharePoint to manage errors in my system, allowing my team to mark whether each error is under analysis or resolved, for example. I’m creating a flow in Power Automate so that whenever they change this status, my flow checks what change was made and adds the start date of that status.

    The issue is I want my flow to trigger only when the status changes. Unfortunately, I don’t think it’s possible to configure this in the trigger, so I’m validating it within the flow itself by comparing the current item version with the previous version.

    However, not all changes involve altering this status, and sometimes users make several changes within a minute, and my Power Automate is triggered only by the last modification. It seems to be a limitation of this trigger.

    Do you have any suggestions on how to handle this scenario? I know one option would be to customize the SharePoint Lists form using PowerApps to detect only these status modifications, but I’d like to avoid that for now as I don’t have the time to customize it at the moment.

    Thanks in advance

Leave a Reply

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