One of the long outstanding improvements needed in Microsoft Flow has been discussed for a long time. Solutions provided have always been either too complicated or just impossible to work with. Related to this issue is also the difficulty to find out previous values of the list items in SharePoint in your flows.
Last week I responded to this discussion with an idea that might help a lot of people get around the issues.
The general idea is to have a shadow list. In this post I’m hoping to give some more details.
The Lists
I’ve created a list with 2 columns. Both Column1 and Column2 are simple text fields but they could be of any type.
Then I created an identical Shadow List
The Flow template
I’m now starting with a trigger that will start my flow every time an item is created or updated in My List
In my example I’m going to go for the naive option and I’m going to assume that the ID of my items will always match. This might be a risky approach as I will have no control over this field when a new Shadow item is created. Therefore most likely it would be better to create some additional fields in each list so that the items in the lists are linked more reliably. For simplicity of this post however I’ve used the IDs of items in both lists.
Straight after my trigger I’m collecting the matching item from the shadow item:
This will however fail when we are looking at a newly created item.
Now all we need to do is to update the item in the Shadow list when the Flow completes so that the next time we run the flow we will have the previous values stored in the Shadow list.
So far I have not looked at my 2 issues:
- Trigger on specific field
- Get previous values of the triggering item.
Trigger on specific field and get previous values
to trigger on a specific field all I need to do is add a condition ( you could even trigger on a combination of fields now!). In my example below, I’m comparing the values given my the trigger with the values of the Get Item action that I described earlier.
Then inside the yes branch I’ve added a scope. This scope will need to contain all the steps that I want to run when a specific field has been updated.