Search

Updating SharePoint List Items and triggering Flows - be careful with timing!


So recently I had a problem with a PowerAutomate (Flow) triggered from a button on a PowerApps form. This Flow just would not fire correctly in certain circumstances. Took me a while to figure it out, so thought I'd share!



What's the context?

I have a SharePoint list for Incident Management, overlaid by a PowerApps form which allows an investigator to be allocated to an Incident Investigation.

Clicking the Allocate / Reallocate Investigator button (above) triggers a simple PowerAutomate / Flow, which sends an email to the Investigator specified in the Investigator box.


Simple enough - so far, so good!



So what's the problem?


Clicking on the Incident List Item in the SharePoint list directly opens the PowerApps Form, allowing the user to set an Investigator and click the "Allocate" button; the Flow fires, and everything works perfectly. Investigator gets an email, and off they go to investigate the incident!


BUT - clicking on an emailed link to the Incident List item still opens the PowerApps Form. However, setting an investigator and clicking the "Allocate" button just does not work. The Allocated User does not receive the email. Bah!



So what's causing this?


After a lot of head scratching - turns out it's a simple timing issue!


Clicking on the "Allocate" button in the PowerApp form does two things - it submits the Form to SharePoint (to save the values), and triggers the Flow to send the Email to the allocated investigator.


However, due to a weird timing issue in SharePoint, when the form is opened from a direct link to the list item, it seems to be slower in saving values to the underlying SharePoint list; meaning that when the Flow runs, it appears that the "Investigator" field is still blank - and hence the issue!



And the solution?


Really simple when you know what the problem is! Simply adding a 10 second delay into the Flow to give SharePoint time to commit the values to the underlying SharePoint list allows the Investigator value to be stored correctly, ready for the Flow to pick it up. Simple!




13 views0 comments