#PowerPlatformTip 21: 'Use Triggeroutput'
TL;DR: Use triggerOutputs()?[‘headers’] to pull request header data like the flow starter’s email, so you can notify them and handle errors.
💡 Challenge
By default, flows don’t inform the user of success, details, or errors. How can you notify the flow initiator and handle potential errors within your flow?
✅ Solution
Use the triggerOutputs() expression to extract header information, send notifications to the flow starter, and manage errors.
🔧 How It’s Done
Here’s how to do it:
-
Capture the user’s email from the request headers. 🔸 Use the expression:
1
triggerOutputs()?['headers']?['x-ms-user-email']
-
Include additional header information as needed. 🔸 Use the expression:
1
triggerOutputs()?['headers']
-
Configure subsequent actions (e.g., send an email) using these outputs.
🎉 Result
The flow now notifies the flow initiator upon success with relevant header information and handles errors gracefully.
🌟 Key Advantages
🔸 Provides real-time notifications to the flow initiator.
🔸 Extracts header data easily with built-in expressions.
🔗 Related Tips
🔸 #PowerPlatformTip 126: ‘User Context for Automated Tasks’ - another way to act on who started or owns a run, without hardcoding a single account.
🔸 #PowerPlatformTip 98: ‘Secure Inputs, Secure Outputs’ - mask the email and header data this expression exposes in the flow’s run history.
🛠️ FAQ
1. Does triggerOutputs() work with all trigger types?
Most trigger types support triggerOutputs(), but the available data varies. Manual triggers and HTTP requests typically provide the most header information.
2. What other header information can I extract besides user email?
You can access user agent, IP address, authorization tokens, and custom headers depending on the trigger type and source.
3. How do I handle cases where the user email is not available?
Use conditional logic or the Coalesce function to provide fallback values when header information is missing or null.
This tip is by Marcel Lehmann, Microsoft MVP (Business Applications) and founder of the Power Platform Academy – live Power Platform workshops, free or CHF 49. Join the workshop waitlist to get notified about new dates. For companies that want this implemented for them, see KMUpower – Power Platform consulting & automation for SMEs (DACH).
