You've built an amazing Vacation booking solution in Power Apps that allows for easy approvals using components like a date picker. But how do you take it to the next level and automatically generate Outlook calendar events when time off is approved? In this post, I'll walk through a simple way to make this happen with Power Automate.
The Problem with Date Pickers
Power Apps date pickers are great for selecting dates for events, time off, appointments etc. But one limitation is that they only allow choosing a date, not a specific time. The date picker defaults any selection to midnight (00:00) for the time.
This doesn't work when you need to create real calendar events, like in Outlook, which require both a start and end date and time. Under the hood, Outlook events also expects to be talked to in values which align to the ISO 8601 formatted standard so you it's not just a case of passing it a value from your data picker and letting it do the rest!
The Solution with Power Automate
With a few simple steps, using Power Apps and Power Automate in tandem, we can:
- Allow the user to pick a time value to go with their date selection
- Build the properly formatted ISO datetime string required for Outlook within Power Automate
- Create the calendar event dynamically in Power Automate
Here's how:
- Add controls in Power Apps to allow for a time value to be input by the user as well as a using a date picker. If you ONLY ever want the leave bookings to run for full days, you can hard code the time values into Power Automate but I'd recommend adding flexibility.
- A quick tip for creating the time drop downs - use the Sequence() formula to create a list of numbers for the drop down e.g Sequence(12) will give you 12 hours to pick from in a list within the Drop Down control.
- Pass the data from the controls into a Power Automate flow as Input variables.
- Construct the full timestamp within Power Automate by using a Compose. Within this, you can concatenate the date from your date picker with the chosen time values.
- To comply with the ISO format standard, include "T" after the date to indicate the beginning of the time values.
- Be sure to add ":00" to the string at the end to format it properly with years, months, days, hours, minutes and seconds data included.
- Use Replace() to change what PowerApps gave you in the date ("/") with "-" to complete the ISO format needed.
- Finally, use the "Create event" Outlook connector action to create the calendar event, passing it the formatted date/time strings as the start and end values.
With these simple steps, your Power Apps date selection can now automatically create a corresponding Outlook calendar event when a date is chosen! The user experience is smooth and seamless.
Unsure how to complete all these steps?
Watch the video at the top of this post for a step-by-step instruction.
Next Steps
There are many ways you could build on this solution:
- Enhance it by allowing the user to choose event names, details etc
- Build in validation and error handling to catch any issues with dates and times
- Experiment with launching Calendar events directly within Power Apps (yes this IS possible!)
If you want to learn how to build a fully functioning and scalable Holiday booking solution with the Power Platform, sign up to take our on demand Vacation Booking course via our Platinum Plan.