Best way update list item in SharePoint using Power Automate – Microsoft 365

Best way update list item in SharePoint using Power Automate – Microsoft 365

No comments

Loading

In this “update list item in SharePoint using Power Automate” tutorial, we will learn how best we can update a single list item using the Power Automate “Send an HTTP request to SharePoint” action without getting into the very common issue like “Actions in this flow may result in an infinite trigger loop. Please ensure you add appropriate conditional checks to prevent this flow from triggering itself”

Traditional way update an item in SharePoint list using Power Automate

In general, if we want to update an item in the SharePoint list using Power Automate, we will add the trigger entry action on created or modified let’s say here it is – “When an item is created in or modified”.

Update Item in SharePoint list using Power Automate
Update an item in the SharePoint list using Power Automate

Then we will add the “Update item” action like below:

Update an item action in Power Automate
Update an item action in Power Automate

Parameters to update item action in Power Automate

Below are the parameters that need to be passed in the update item action:

  • ID: Mandatory (Select the ID from When an item is created or modified action).
  • Title: Mandatory (Select the Title from When an item is created or modified action).
  • Rest all optional parameters – in this demo, we are updating the “ProjectName2” text column with the “ProjectName” lookup column value, so, here also need to select the ProjectName Value from the “When an item is created or modified” action.

Now, when we save the flow, we get the warning message:

“Actions in this flow may result in an infinite trigger loop. Please ensure you add appropriate conditional checks to prevent this flow from triggering itself”

Action in this flow may result in an infinite trigger loop
Action in this flow may result in an infinite trigger loop

But the flow will work fine – if we update something in the list, the “ProjectName2” text column will be updated with the “ProjectName” lookup column value, but in the background, the flow will run multiple times for the single item, technically it will go to the infinite loop, please look at the below screenshot. We have just updated a single item in the list, but the flow went on an infinite loop.

Power Automate update list item infinite loop
Power Automate update list item infinite loop

We can fix this issue by adding some conditions to the flow before executing the update item action, however, we are not convinced with this, below are the points why:

  • We want to just update another column irrespective of any things changes for that particular list item. So, why check the condition?
  • We are passing the “ID” column from the “When an item is created or modified” action to the “Update Item” action, so, technically we are saying to update the single row (list item) for the given ID, then why this execution went on infinite?

Instead of fixing this infinite looping issue in Power Automate flow and adding unwanted conditional checks, we can update the single list item in Power Automate without getting into unwanted noises (infinite looping issue).

Before getting into that let’s learn how to take a backup of Power Automate flows or maintain multiple versions of the same flows. Because in the current flow we have both the action Update Item as well as Send an HTTP request to SharePoint, we need to create separate two flows for these two individual actions using the Save As feature in Power Automate.

How to take backup of Power Automate flows: Save as in power automate

To use the Save As feature in Power Automate we need to follow the below steps:

  1. Log in to the Power Automate Manage your flows using this URL –  Manage your flows | Power Automate.
  2. Select your environment from the Environments selection dropdown list.
  3. Select your Power Automate flow for which you want to perform “Save As”.
  4. Click on the “Save As” button from the top menu (shown as 3).
Save as in Power Automate to create another copy of the same flow
Save as in Power Automate to create another copy of the same flow

Next, we will get the pop-up screen – Create a copy of this flow, with the below description.

“We’ll create a copy of this flow and add it to your My flows page. You can rename it first if you want. It’ll be turned off by default.”

Create a copy of this flow in Power Automate
Create a copy of this flow in Power Automate

Notes:

  • We can name the flow as per the needs, here we are keeping the name as the default “Copy of – Update SharePoint Single Item in List”.
  • This flow will be turned off by default, however, we can enable it whenever we need it.

Update an item in SharePoint list using Power Automate “Send an HTTP request to SharePoint action”

Now, we will try to update a single item in Power Automate using the “Send an HTTP request to SharePoint” which is a more robust approach and this does not go to the infinite looping execution.

In the flow, now we have only the “Send an HTTP request to SharePoint” action and removed the “Update Item” action.

Send an HTTP request to SharePoint to update a single item in Power Automate
Send an HTTP request to SharePoint to update a single item in Power Automate

If we notice the flow, we don’t see the below warning message anymore:

“Actions in this flow may result in an infinite trigger loop. Please ensure you add appropriate conditional checks to prevent this flow from triggering itself”

Now, let’s expand the “Send an HTTP request to SharePoint” action.

Send an HTTP request to SharePoint to update a single item in Power Automate - Action explanation
Send an HTTP request to SharePoint to update a single item in Power Automate – Action explanation

Explanation:

  • Site Address – Your site URL
  • Method – POST
  • Uri – Refer to the syntax section, here just update your list title and pass the item ID from the “When an item is created or modified” action.
  • Body: In this section pass your field’s internal name and the value to update.

Validateupdatelistitem REST API in SharePoint Online – Syntax

Site Address: 


Your site URL

Method:


POST

Uri:


  _api/web/lists/GetByTitle('Your list Title')/items("Item ID for which want to update")/validateUpdateListItem

Body:

{
"formValues":[
{
"FieldName": "FieldInternalName",
"FieldValue": "Pass the value that you want to update"
}
]
}

In the above syntax, all the parameters are straightforward, only need to know how to get the field’s internal name in SharePoint.

How to get internal field name in SharePoint (update item in SharePoint list using Power Automate)?

Follow the below steps to get the internal field name in SharePoint:

Step 1: Sort the column for which you want to get the field’s internal name.

Step 2: Get the sortField=”Field internal name” from the URL bar.

How to get internal field name in SharePoint
How to get an internal field name in SharePoint

Summary: What we have learned here (Update list item in SharePoint)?

Thus, in this article, we have learned the below with respect to updating the item in the SharePoint Online list:

  • How to update SharePoint list item using the Power Automate “Update item” action.
  • How to use Save As in Power Automate flow to maintain various copies of the same flow.
  • How to use the “Send an HTTP request to SharePoint” action to update an item in the SharePoint Online list.
  • How to use the “Validateupdatelistitem REST API” in SharePoint Online using Power Automate.
  • How to get internal field name in SharePoint.

See Also: Power Automate Tutorial

You may also like the below Power Automate tutorials:

 

 

 

About Post Author

Do you have a better solution or question on this topic? Please leave a comment