Troubleshooting using environment variables in Power Apps and Automate packed in Solution

HK SharePoint Admin
4 min readJun 17, 2022

Recently I am working on the package a solution and deploy to Test and then Production environment. It is a simple solution with 1 Power Apps + 3 Power Automate flows only. Data source is SharePoint online solely. The time I spent on troubleshooting and debugging is more than development time.

To put this article short I will directly list out the problems I encountered and how I solved them.

This environment variable definition cannot be edited because it is in a managed solution.

I inserted several environment variables into my app and flows. After export as managed solution and import to new environment, the variables become readonly like below.

It suppose to be editable. The problem is that I should not create environment variables manually. In Power App studio, goto Settings > General > turn ON “Automatically create environment variables when adding data sources”.

Then delete all my created variables. Delete all my data sources in App and then recreate. During recreate the source, Power App studio will ask whether variable be created as well. Let it create for you. Then you will get the new and working variables.

After variables are created, your need to remove the VALUES in variables before export with solution.

Left screenshot is a variable with value. Click on the DOWN arrow > Remove. Then you will get a variable without value like the right screenshot.

When you import solution to new environment, you will be asked to input them again like below screenshot:

Some articles suggest you should make the variable empty before export. It didn’t help in my case.

By search it online it lead to the bug discussion here. It suggest you edit the variable in dataverse. I don’t do that because it is not a Microsoft suggested approach. It may be a quick workaround here but it may be harmful in long run.

This variable didn’t save properly. A record with matching key values already exists.

After you import the solution in new environment, when you try to edit a data source variable (in my case it is a SharePoint list) you get above error.

To solve it, click Save button twice. If it doesn’t work, close the edit panel, open again and save again.

It is stupid but it is Microsoft UI, isn’t it?

Turn on failed. Flow client error returned with status code “BadRequest” and details “{“error”:{“code”:”InvalidOpenApiFlow”,”message”:”Flow save failed with code ‘DynamicOperationRequestClientFailure’ and message ‘The dynamic operation request to API ‘sharepointonline’ operation ‘GetTable’ failed with status code ‘NotFound’.

After you import the solution to new environment, the flows are in Off status. When you try to turn them ON you get above error.

It is because the flow have reference to environment variables. Some or all of variables are not working property in new environment.

First thing you need to check is open the flow in editor, then check which variable is not working. Then edit the variable in your new environment. Make sure the value is properly input and save.

Workflowname.Run failed: Connection not configured for this service.

After import the solution and test run the App. I found a App calling workflow is not working for user (it works for me who is the flow owner). The app have a button to trigger a flow. When user press the button a red bar prompt up for above error.

To solve it, in Power App studio, open data source panel and delete the association with that workflow. Save the app and close. Open the app again and add back the association.

I believe the connection failed when it is being imported as solution.

--

--