I've seen frequent posts in the Flow Forums from users asking how they can check for a change is a specific column in a SharePoint list, If the value has changed, they want to take some type of action. I have usually answered these questions by saying that this is not an "out of the box" Flow feature. There actually is a way to check for a change in a SharePoint list column value and it isn't very difficult to implement. It does involve calling a SharePoint web service, but I'll show you exactly what you need to do.
First, let me set some parameters:
Step one is to create a Flow that uses the SharePoint "when an item is created or modified" trigger. Since this Flow checks for changes in a column value, it doesn't make sense to run the Flow on a new entry. The first part of my Flow checks to see if the created date and time is the same a the modified date and time. If they are the same, then this is a new item and the Flow exits with a Control Terminate action.
Please note that the Terminate action status is set to Succeeded - the default is Failed. If you don't change the status to Succeeded, your Flow will show as failed when a new item is created even though it ran as designed.
Next, I set a variable that holds the list item ID. I'll use this variable when I call the SharePoint web service.
Now for the good stuff - next I call the SharePoint Web service. I use a "Send an HTTP Request to SharePoint" action. The particular API that I'm calling returns all versions of a list item along with all columns and data in those columns. Configure your "Send an HTTP Request to SharePoint" action in exactly the same way as I have in the screen shot below except:
Note that I am inserting the variable where we stored the item ID in the web service call.
At this point, when creating your own Flow, save it and run it by making a change to an item in your list. Remember that you'll need to have at least 2 versions of an item for your Flow to make it all the way to the HTTP call and we will need information returned by the HTTP call in the next step.
After the Flow runs, take a look at the run history and do the following:
Now, I add a Parse JSON action. This action enables us to easily use all the data returned by the HTTP action.
In the Parse JSON action content section, select Body from the Send an HTTP request to SharePoint section in Dynamic properties. Now, click on "Use sample payload to generate schema". In the dialogue box the appears, paste the data on your clipboard (copied form the HTTP Body section) and click on Done. This will automatically configure this action to interpret the data provided by the HTTP action.
When complete, the Parse JSON action should look like this:
Almost done - all we need to do now is to retrieve the value we are comparing from the previous version of the list item and compare it to the value in the current version.
Next, I create a string variable and initialize it to the value of the column in which we are interested from the previous version of the list item.
Here's what I have in the expression:
Referencing the column name requires a little more explanation. If there are no spaces in the column name you can probably just enter the column name. If there are spaces in the column name or you just want to be sure you are using the right name, go to the Parse JSON action and scroll down in the schema section until you see something that looks like your column name. Here is a section from my schema that refers to a few columns:
I have a column called MyChoice with no spaces which I can refer to as MyChoice. I also have a column called My Date. I need to refer to this column as My_x005f_x0020_x005f_Date.
All I need to do now is to compare the current value in the column to value from the previous version (stored in the variable).
I found the following blog post extremely helpful when creating my solution
Please comment and let me know what you think.
Scott