Hi,
I've tested your question in my test lab, and it works as expected. When I add the code you wrote to my trigger condition it only triggers when files are added in /General or /source (and subfolders), but not in other root folders.
Just to make sure it's in the right place, I've set my trigger to fire on the root folder of my site collection, the clicked the "three dots" and selected "Settings":
Next I've added your code to the trigger condition:
For completeness, I've used this code:
@or(startsWith(triggerBody()['{Path}'], 'Shared Documents/source/'),startsWith(triggerBody()['{Path}'], 'Shared Documents/General/'))
It works as expected.
I've added my Logic App code for your reference (you can copy/paste it but be sure to change the following details to your own (for the connection part you could also reuse from your current Logic App):
- {SiteCollectionUrl} to your Site Collection's URL
- {DocumentLibraryGuid} to your Site Collection's document library GUID
- {SubscriptionId} to the Azure subscription ID of your Logic App and connection file
- {ResourceGroupName} to the name of your Logic Apps' resource group
- {Location} to the location your resource group is in
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"When_a_file_is_created_or_modified_(properties_only)": {
"conditions": [
{
"expression": "@or(startsWith(triggerBody()['{Path}'], 'Shared Documents/source/'),startsWith(triggerBody()['{Path}'], 'Shared Documents/General/'))"
}
],
"evaluatedRecurrence": {
"frequency": "Minute",
"interval": 3
},
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['sharepointonline']['connectionId']"
}
},
"method": "get",
"path": "/datasets/@{encodeURIComponent(encodeURIComponent('{SiteCollectionUrl}'))}/tables/@{encodeURIComponent(encodeURIComponent('{DocumentLibraryGuid}'))}/onupdatedfileitems"
},
"recurrence": {
"frequency": "Minute",
"interval": 3
},
"splitOn": "@triggerBody()?['value']",
"type": "ApiConnection"
}
}
},
"parameters": {
"$connections": {
"value": {
"sharepointonline": {
"connectionId": "/subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Web/connections/sharepointonline",
"connectionName": "sharepointonline",
"id": "/subscriptions/{SubscriptionId}/providers/Microsoft.Web/locations/{Location}/managedApis/sharepointonline"
}
}
}
}
}
Please let me know if my answer is helpful, and if so click "Accept answer" and upvote it. Feel free to drop additional queries in the comments below.