In this tutorial, Jonathon Silva from Pragmatic Works walks through how to manage null values and empty lists in SharePoint using Power Automate. These scenarios often cause issues in flows, especially when dealing with incomplete data. This guide explains how to build robust flows that handle these conditions effectively.
The example uses an Employee Time Card SharePoint list with three columns:
The goal is to ensure that employees cannot clock in for a new day without clocking out from the previous day. If a clock-out is missing, the flow should send a reminder email instead of creating a new entry.
Jonathon demonstrates a basic flow that:
addHours(utcNow(), 3) for EST).This works for simple clock-ins but fails when previous entries lack a clock-out time.
To handle missing clock-outs, Jonathon adds a Get Items action:
Title eq 'username'ID in descending order and limit to 1 item (the most recent entry).Next, a Condition checks if Clock Out Time equals null. If true, the flow sends an email reminder; if false, it creates a new clock-in entry.
What if the SharePoint list is empty? The previous condition won’t run because there’s nothing to check. To fix this, Jonathon adds another condition using the length() expression:
length(body('Get_items')?['value']) checks if any items exist.Title eq 'username'.null using expressions.By implementing these checks, you can create resilient Power Automate flows that handle real-world scenarios like missing data and empty lists. This approach is essential for maintaining accurate records and improving workflow efficiency.
Thanks for following along! Stay tuned for more Power Automate and SharePoint tips from Jonathon Silva and Pragmatic Works.
Don't forget to check out the Pragmatic Works' on-demand learning platform for more insightful content and training sessions on Power Automate and other Microsoft applications. Be sure to subscribe to the Pragmatic Works YouTube channel to stay up-to-date on the latest tips and tricks.