This can be done with a few SharePoint Http requests to the REST api. The first one to break the document's permission inheritance, another one to get the current user's ID from the SharePoint user list and the last one to set the permissions.
The library title is in the variable
myLibrary, the document ID is in the variable
myDocumentID. Create a SharePoint HTTP request, select the site and set the method to
POST. The URI will then look like this
Next, get the ID of the user that you want to assign permissions to. If this is run on a document library when a file is uploaded, you can get the user details from the ModifiedBy field. Use the Email address of that user and store it in the variable
UserEmail. Then you can get their ID this way
SharePoint HTTP Request called
GetUserFromEmail', specify site, method isGET`, URI is
This will return a complex user object. You need the
d.ID property. Set the variable
CurrentUserID to this expression
Important: if the action to get the user contains spaces, the body() command must use underscores in place of the spaces for this to work.
Now you can set the item permissions. Add a SharePoint HTTP request, select the site and set the method to
POST. The URI is
roledefid for Edit permissions is above. Contribute would be
1073741827. The standard roledefids can be easily found on the web. If you have custom permissions, you can find all permission numbers when you look at the xml returned by this URL.
Let me know how you get on with this.