This feature ensures that only selected users or groups can view, edit, or manage the folder's contents, enhancing security and tailoring access to meet specific needs.
Creating custom permission level in SharePoint site, we can set folder level permission to the folder in it's subsite document library.
Step 1. Create a subsite in your SharePoint site.
Step 2. Create a Document Library in a newly created subsite.
Step 3. Create a list in the main site with the given fields.
Step 4. Now in the Power Automate, Create a new flow with the File created trigger.
You need to create a folder in the subsite to upload documents.
Step 5. Add a trigger condition.
@equals(triggerBody()?['{IsFolder}'], true)
So the flow will trigger at the time of folder creation only.
Step 5.1. Add a Compose action to get the link to the newly created item.
Step 6. Now, Add an action to create a new list item in the base site. We have added the SiteUrl field value with some string manipulation with the replace function.
replace(outputs('Compose'), triggerOutputs()?['body/{FullPath}'], '')
Step 7. Now get the folder metadata by adding Get Folder Metadata using path action.
Step 8. Again go back to the base SharePoint site and create a new permission level as per the given picture. Permission level should be with Edit permission but with no delete rights.
Step 9. Now, in the flow add one action to get the ID of the newly created permission level.
Step 10. Add the user into the visitor's group of the base site to give read access rights.
Step 11. Add a new action to break the inherited permission of the subsite, to grant our custom permission level access to the user.
Step 12. Add a new action to grant access to the user at the item level. Here we need to add a role in which we can get from the above action.
role: @{body('Send_an_HTTP_request_to_SharePoint_-_Get_Permission_level_ID')?['d']?['Id']}