Power Automate: Actions, Outputs & Body Functions

Power Automate: Actions, Outputs & Body Functions

The Power Automate functions body, actions and outputs allow you to get any inputs & outputs you want from a previous action. These functions are useful because inputs, status codes and headers information do not appear in the dynamic values menu. Once you learn them you will be able to get any data you need to build your Power Automate flows.

Table of Contents
• Introduction: The Paid Time Off SharePoint ListActions Function In A Power Automate FlowGet Input Parameters From A Power Automate ActionOutputs Function In A Power Automate FlowBody Function In A Power Automate FlowGet Value Property From A Power Automate Action




Introduction: The Paid Time Off SharePoint List

The Power Automate flow we will build to learn the Actions function, Body function & Outputs function uses a SharePoint list named Paid Time Off.

  • TimeOffDate – Date Only
  • RequestType – Choices [Personal, Vacation, Bereavement, Sick]
  • Status – Single line text
  • EmployeePerson – Person



Populate the SharePoint list with the following data:

TimeOffDateRequestTypeStatusEmployeePerson
9/1/2020PersonalSubmittedKelly Smith
9/4/2020VacationApprovedKelly Smith
9/5/2020BereavementApprovedKelly Smith
9/8/2020SickRejectedJennifer Houston
9/12/2020PersonalSubmittedSarah Green
9/13/2020VacationApprovedJennifer Houston
9/15/2020PersonalRejectedSarah Green




Actions Function In A Power Automate Flow

The Power Automate actions function gets the inputs & outputs for a selected action and returns it as a JSON. It allows us to use and input/outputs properties from a prior action.

Create a new instant flow in Power Apps, add a SharePoint – Get Items action and target the Paid Time Off SharePoint list. Then insert a Compose action and use the actions function to get input/output values from the Get Items action.



Write this Power Automate expression in the Compose action.

actions('Get_items:_Paid_Time_Off')



The Power Automate actions function returns all inputs & outputs from the Get Items action shown below.



The Get Items action is represented as a JSON.




Input Parameters Property From A Power Automate Action

A specific property from the Get Items action can be selected by writing some additional code after the actions function. For example, lets say we want to get the Site Address used as an input to Get Items.



We would write the following Power Automate expression to get the site address from the JSON returned by the actions function.

actions('Get_items:_Paid_Time_Off')?['inputs']?['parameters']?['dataset']



The Compose action outputs field now shows the SharePoint site address.




Outputs Function In A Power Automate Flow

The Power Automate outputs action returns the status code, headers and body for the selected action as a JSON. It is useful because the status code and headers are not included in the dynamic values shown by Power Automate.



Update the Compose action to use the outputs function.

outputs('Get_items:_Paid_Time_Off')



The JSON returned by the outputs action shows the status code headers and body as expected.



If we wanted to get the statusCode we could write an expression like this to return the value 200.

outputs('Get_items:_Paid_Time_Off')?['statusCode']




Body Function In A Power Automate Flow

The Power Automate body function returns the body property from the selected action. Any property found within the body will be automatically shown in the dynamic values selection menu so it is often not necessary to write the body function manually. But it will appear in the dynamic values you have selected.



Change the Compose action to use the body function instead.

body(‘Get_items:_Paid_Time_Off’)



The JSON returned by the body function looks like the image below. Notice that the status code and headers we saw when using the outputs function are excluded.




Value Property From A Power Automate Action

When a Power Automate action is used to return a list of items it is usually found in the values property of the body. We can write a Power Automate expression to get these values.


Use this code in the Compose action. The body function targets the Get Items action and the selector gets the list of items in the value property.

body('Get_items:_Paid_Time_Off')?['value']



The list of values appears in a JSON format like this:





Questions?

If you have any questions or feedback about Power Automate: Actions, Outputs & Body Functions please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.

Matthew Devaney

Subscribe
Notify of
guest

0 Comments
Oldest
Newest
Inline Feedbacks
View all comments