In a document library folder, when a user creates a new document, instead of it being named 'Document' when created, I want it to be named as the last name of the user. I have explored trying to do this through a Flow but there does not seem to be a way to rename a document. The user cannot rename the document themselves as they do not have delete permission.
2 Answers
Mike's link is very helpful. Do have a check on it. I made a sample flow works in my end.
The"Test Library" is your library name.
The SP.Data part in the body needs to be checked via the following link
https://yourdomain.sharepoint.com/sites/yoursitehere_api/web/lists/GetByTitle('Library name')?$select=ListItemEntityTypeFullName
The last outputs part is your required file name format.
-
The Flow fails with an error 'BadGateway' "message": "The file or folder name contains characters that are not permitted. Please use a different name." Not really sure what I did wrong. Any ideas? Oct 17, 2019 at 14:21
-
@cflasrado would you like to show us your setting in the send an HTTP request action? Oct 21, 2019 at 1:52
-
-
Ok, I managed to get it to work. However, the flow fails with the error the document is checked out to me. Is there a way to delay the flow until the document has been saved or checked back in? Oct 21, 2019 at 19:11
-
@cflasrado change the trigger to when a file is created or modified. Then you can add a if condition on the " check out" property which will indicate the status of the file. Only send the http request when check out is false. I updated with a pic Oct 22, 2019 at 1:30
This is a 2013 style workflow:
This simple demo grabs the full name, but you could use Find Substring in String and one of the Extract Substring actions to pull off the last name.
You will need to configure App permissions to let the workflow do what the user is not allowed to do. (rename)
-
Would this Flow work/be applicable on SharePoint Online because I do not see an action available to Set Name? I only see an action to Update Item or File. Oct 16, 2019 at 20:04
-
The action is called "Set field in current item". The field being set is "Name". Oct 16, 2019 at 20:07
-
I am using Flow and not SharePoint Designer and that action is not available on Flow. Is there a way to achieve what I am trying by using Flow? Oct 16, 2019 at 20:40
-
Ah. Your question said workflow and was tagged workflow. Flow can call the SharePoint web services. This might apply: powerusers.microsoft.com/t5/Building-Flows/… Oct 16, 2019 at 20:46