How to Select a File Dynamically by Environment in Power Automate
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).

- 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.
Ensure you have the necessary permissions in the Power Platform admin center to create and manage environment variables for your solutions.
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.
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'.
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.
In your Power Automate flow, add an action to fetch the environment variable value before the 'Get Rows' action executes.
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.

Consult the Official Power Automate Community
If you encounter specific connector errors when passing custom values to the Google Sheets connector, leverage the Microsoft community for advanced troubleshooting.
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.

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.




