Trigger flow when a folder is created in the SharePoint library
There are many triggers available for SharePoint list and libraries but in some cases, the flow should be triggered only a folder is created or a file is created inside the library, there are no direct triggers available but with the help of conditions we can trigger the flow when needed.
We are going to make use of Trigger conditions in the flow trigger. In this example, we used the “When a file is created (properties only)” trigger.
SharePoint returns the “IsFolder” value whenever the flow is triggered, we will use it in the trigger conditions.
@equals(triggerOutputs()?['body/{IsFolder}'],true)
Now the flow will trigger whenever the folder is created. It can be changed vice-versa if the flow needs to be triggered only a file is created then we can make the condition as false.
But here is one additional use case, if the flow needs to be triggered when a folder is created as a Parent folder and it should not be triggered when it is created inside another folder.
We need to make use of the “LinktoItem” property and see whether it is a parent folder.
@equals(length(split(split(triggerOutputs()?['body/{Link}'],'LibraryNameFromURL')[1],'/')),2)
Please post your queries in the comment section. Happy Building š
What would our LibraryNameFromURL be? I have the /Shared%20Documents/Forms/AllItems.aspx? then it goes on to a whole bunch of numbers for the url.
It is just the Library Name from the URL.