Share via


Remove Unused PowerApps Variables from Power Automate

  • Introduction
  • Problem Statement
  • Solution
  • Summary

 

Introduction

A common requirement while working with Power Apps is to call Power Automate from the app and pass parameters to the flow for executing a logic.

Within Power Automate, we can Initialize the variable using the “Ask in Power Apps” property which will create the variable by the name <ActionName>_Value. We can use this within the flow expecting that value will be passed as an input parameter from Power Apps

To pass value to the above initialized variable, we use the <FlowName>.run(<Parameters>) expression in the OnSelect of the button within the Power App.

 

Problem Statement

When we are using the Initialize variable action and clicking the Property Ask in Power Apps, it created a variable for use within the flow. However if we have by mistakenly clicked the “Ask In Power Apps” property for a second time, it will create a second variable and it will be a mandatory variable for which value has to be passed from Power App.

There is no way to easily remove the duplicate variable created in the Flow. As of writing of this article, this is still a user requested feature in the User Voice.

If we head over to the Power App, we can see the Flow calling expression will be expecting a second value now, due to the newly added variable.

Solution

Currently there is no way to manage the created variables in Power Automate or make the passing of parameter optional as Flow expects both as mandatory values. The workaround as of now is to delete the Power Apps trigger in the Flow and re add the trigger which will remove all the created variables and we can re add the needed variable back using the “Ask in PowerApps” property.

Now we can re add the PowerApps trigger and head over to the Initialize Variable action and add the Variable once again

Thus, it has added just one variable which we will be passing in from Power App

Summary

Thus, we saw how to manage the duplicate or accidental Power App variables created in Power Automate as we don’t have a straight forward way to manage the variables inside Power App or Power Automate.