Check if an item is new or edited

Learn how to see if an item has been created or modified, and create different automations based on that value


In some cases we want to perform different automations depending on if an item has been created (new) or has been modified (edited)

To do this we can use the action “Get changes for an item or a file”

In my example below we will send an e-mail with a specific text if the item is new, and another e-mail if the item has been edited

As your first input action insert When an item is created or modified

Next, insert the action Get changes for an item or a file (properties only)

  • Id = ID from your previous action.
  • Since = Trigger Window Start Token from your previous action

This action returns which properties have been editied, and is returning it as true of false value (it does not return the actual value, like “old” value and “new” value)

Looking at the “raw output” of the Get changes… action we can see that we get the following output

"body": {
        "SinceVersionExisted": true,
        "SinceVersionId": 512,
        "SinceVersionLabel": "1.0",
        "UntilVersionIsCurrent": true,
        "UntilVersionId": 1024,
        "UntilVersionLabel": "2.0",
        "ColumnHasChanged": {
            "ID": false,
            "Title": true,
            "OData__x0031_23": true,
            "calculated": false,
            "OData__ColorTag": false,
            "ComplianceAssetId": false,
            "Modified": true,
            "Created": false,
            "Author": false,
            "Editor": false
        }
    }

From the code above, we can see that the SinceVersionExisted = true and the Title = true which means that the item has been edited, and the Title field has been edited

Condition

Insert a new action from the Control library called Condition

If you go back to the code/output above, you can see it returns an modified value, but unfortunately this property always returns true. So we can’t use that option.

If you search for the SinceVersionExisted in your dynamic content we can’t find it since it is outside the ColumnHasChanged

To work with this option, we need to write our own expression:

outputs('Get_changes_for_an_item_or_a_file_(properties_only)')?['body/SinceVersionExisted']

A short explanation of the code

With outputs we are telling Power Automate to get the outputs from the action

Get_changes_for_an_item_or_a_file_(properties_only) (note that spaces are replaced with _ )

Then we add a ? which means that IF an output exist, it should return from body the value of SinceVersionExisted (true or false)

Now that we know if an item is new (false) or edited (true) we can create two different e-mails like below 👇

Now you now how to check if an item is new or edited. This will also prevent your flows from going into an infinite loop ‎


See also