I am trying to create a Power Automate flow that triggers when a file is created in a specific folder within a SharePoint site. The trigger I am using is "When a file is created (Properties only)", and it works perfectly when I provide the inputs as fixed values for:
SharePoint site address
Library name
Folder path
However, I need to make these inputs dynamic to allow flexibility across environments. Here's what I've done so far:
Created environment variables for the SharePoint site address, library name, and folder path.
Added these environment variables to a solution in Power Automate.
Configured the flow within the solution to use these environment variables for the trigger inputs.
After these changes, the flow does not trigger when I add a new file to the specified folder.
Verified that the environment variable values are correct and point to the right site, library, and folder.
Tested the flow by replacing the dynamic inputs with static values, and it works as expected in this case.
Confirmed that I have the necessary permissions on the SharePoint site and library
How can I correctly use environment variables in the "When a file is created (properties only)" trigger to make the inputs dynamic?
Are there specific configurations or limitations for using environment variables with this trigger?
It's not as simple as it otherwise looks. If you want to see what values the environment variables should have, you need to configure the trigger with the static values provided to you in the drop downs first ...
... and then from there, you need to navigate to the Code view where it will give you the actual values the operation expects.
In the case of that trigger, the Library Name
will be your problem. It expects the GUID of the drive ID, not the name itself.
For the above image, this is how my Code view looks ...
{
"type": "OpenApiConnection",
"inputs": {
"parameters": {
"dataset": "https://xxx.sharepoint.com/sites/TestSite",
"table": "8b487360-db75-4cb9-86c1-a94ad87d5971",
"folderPath": "/Shared Documents/General"
},
"host": {
"apiId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline",
"connection": "shared_sharepointonline",
"operationId": "GetOnNewFileItems"
}
},
"recurrence": {
"interval": 3,
"frequency": "Minute"
},
"splitOn": "@triggerOutputs()?['body/value']"
}
Site Address = dataSet
Library Name = table
Folder = folderPath
... you can see the Site Address
and Folder
are straight strings so you can supply those as is but the Library Name
is not and that's what you'll need to take care of.