Now, for all the newbies working with Common Data Service (Current Environment) connector face a little constraint in order to read certain fields which are NOT in the list of the Dynamic Content of the CDS connector itself.
Let’s say you want to read this field from the Body / Outputs of the CDS trigger in a Flow in Power Automate
Attributes (or rather supporting metadata) won’t be accessible directly since it’s not from the context of the CDS connector itself like you see for other fields as below –
In this example, here’s how our Flow will look like.
We’ll declare 2 variables after the CDS connector with Create or Update trigger on Accounts entity and how we can work with the results.
Reading from triggerBody()
When to use triggerBody() ? – When you want to fetch attributes from the body of the trigger.
Here’s how you can use triggerBody() function to read ‘RunAsSystemUserId’ from the outputs of CDS connector.
- Let’s say you have a variable declared to store your results. Let’s call it Trigger Body. Click on the fx sign to enter the formula
- Now, in the formula, enter triggerBody()?[‘RunAsSystemUserId’]. triggerBody() is a method to you’ll find it in auto-complete
- And the variable will look like this
Result of triggerBody() will be as below
Reading from triggerOutputs()
When to use triggerOutputs() ? – Whenever you need to access anything from within the body as well as some info from the header as well as shown in the 2nd screenshot in step #2 below.
Here’s how you can use triggerOutputs() funtion to read ‘RunAsSystemUserId’ from the outputs of CDS connector
- Let’s say you have a variable declared to store your results. Let’s call it Trigger Output. Click on the fx sign to enter the formula
- Now, in the formula, enter triggerOutputs()?[‘body/RunAsSystemUserId’]. triggerOutputs() is a method to you’ll find it in auto-complete.
The reason this we write “body/RunAsSystemUserId” is because in the JSON structure of the complete Outputs of the CDS Connector, you’ll see that RunAsSystemUserId attribute lies inside body in the JSON.
Whereas in terms of triggerBody() above, we are reading attributes from the “body” itself.
Result of triggerOutputs() will be as below
Hope this was useful!
Here are some more Power Automate / Flow posts you might want to check –
- Call HTTP Request from a Canvas Power App using Flow and get back Response | Power Automate
- Send a Power App Push Notification using Flow to open a record in Canvas App | Power Automate
- Accept HTTP Requests in a Flow and send Response back | Power Automate
- Terminate a Flow with Failed/Cancelled status | Power Automate
- Adaptive Cards for Teams to collect data from users using Power Automate | SharePoint Lists
- ChildFlowUnsupportedForInvokerConnections error while using Child Flows [SOLVED] | Power Automate
- BPF Flow Step as a Trigger in CDS (Current Environment) connector | Power Automate
- Pause a Flow using Delay and Delay Until | Power Automate
- Generate Dynamics 365 record link in a Flow using CDS connector | Power Automate
- Text Functions in a Flow | Power Automate
- Loop through array of objects in a Flow & Create records in CDS | Power Automate
- Get Count of records retrieved in CDS connector in a Flow | Power Automate
4 thoughts on “Using triggerBody() / triggerOutput() to read CDS trigger metadata attributes in a Flow | Power Automate”
How did you build those ‘TriggerBody’ and ‘TriggerOutput’ controls I don’t see it as an Option in the Flow builder?
Hi Simon, can you check if you have turned on Experimental Features for Flow. Alternatively, please do Ctrl + Shift + Space or Ctrl + Space to force the Menu.
Refresh the browser once as well. I’ve faced this before, but not sure on what occasion. Hope this helps!
Great job, thanks. I just had to make some modifications tu your expression:
add(div(add(dayofyear(addDays(subtractFromTime(utcNow(), if(equals(dayofweek(utcNow()),0),6,sub(dayofweek(utcNow()),1)), ‘Day’),3)),6),7),1)
LikeLiked by 1 person
Wow!! That’s quite something. Glad this article was helpful for you.