logo
search
Others

How to Select a File Dynamically by Environment in Power Automate

Natalie TaylorNatalie Taylor Oct 10, 2026 869 views

Question details

The user needs to select a Google Sheets file dynamically in Power Automate Desktop based on the current deployment environment (development, test, or production).

How to Select a Power Automate File Dynamically by Environment
Product
Power Automate Desktop
Device & OS
not provided
Scenario
Deploying automation flows across different environments (Dev, Test, Prod) where each environment requires a different source file for data operations.
Observed behavior
The 'Get Rows' action for Google Sheets currently requires a manually selected file, causing the flow to break or require manual reconfiguration when moved to a different environment.
Before you start

Ensure you have the necessary permissions in the Power Platform admin center to create and manage environment variables for your solutions.

Solution 1Recommended

Use Environment Variables for Dynamic File Selection

Create an environment variable to store the file path or identifier, allowing the flow to automatically use the correct file when deployed to different environments.

Instead of hardcoding the file path in the 'Get Rows' action, you can use environment variables. These variables store parameter keys and values that can be changed depending on whether the flow is running in development, testing, or production.

1
Create an Environment Variable

Navigate to your solution in Power Automate. Click 'New', select 'More', then choose 'Environment variable'. Name the variable (e.g., GoogleSheetFileID) and set the Data Type to 'Text'.

2
Set Environment-Specific Values

Provide the default value (e.g., the Development file identifier). When importing the solution into your Test or Production environment, you will be prompted to enter the current value for that specific environment.

3
Retrieve the Variable in Your Flow

In your Power Automate flow, add an action to fetch the environment variable value before the 'Get Rows' action executes.

4
Apply Dynamic Content to the Action

In the Google Sheets 'Get Rows' action, clear the manually selected file. Select 'Enter custom value' and map it to the dynamic content output of your environment variable.

Use Environment Variables for Dynamic File Selection
Automation Tip: Using environment variables is best practice for Application Lifecycle Management (ALM) in Power Platform, ensuring smooth deployments between environments without manual edits.
Free Microsoft Office alternative

Need a Reliable Spreadsheet Editor for Your Data Workflows? Try WPS Office

While configuring complex automation flows in Power Automate, you need a dependable office suite to manage, review, and edit your source spreadsheets. WPS Office is a free, powerful alternative that handles heavy data seamlessly.

Easily format and manage your environment-specific spreadsheets locally before integrating them into automated workflows.Highly compatible with Microsoft Excel (.xlsx) and CSV formats, ensuring data consistency for Power Automate processing.Free, lightweight, and loads instantly without consuming heavy system resources.Familiar tabbed interface makes it easy to switch between your dev, test, and production data sets.
microsoft office alternative - wps office

Frequently Asked Questions

Why does the 'Get Rows' action fail when I enter a custom file path?

Connectors like Google Sheets often require a unique backend File Identifier (ID) rather than a traditional folder file path. Ensure your environment variable stores the exact File ID extracted from the file's sharing link or properties.

Can I use dynamic content directly from a previous action instead of environment variables?

Yes. If an earlier step in your flow (like 'List files in folder') retrieves the file metadata dynamically, you can pass the output ID from that step directly into the 'File' field of the 'Get Rows' action by selecting 'Enter custom value'.

What is the best way to handle different environments in Power Automate Desktop without premium features?

If you do not have access to premium ALM features or Dataverse environment variables, you can read from a local configuration file (like a JSON or Excel configuration file stored on the desktop) at the start of your flow to determine which file paths to use.

Will I have to update the file ID every time I move a flow from Test to Production?

If you use solution environment variables, you will only need to input the Production file ID once during the initial solution import. Subsequent updates to the flow will retain the environment-specific values.