How to lock a document in SharePoint Workflow 2013
-
17-12-2020 - |
質問
I've created an app (add-in) in Visual Studio for SharePoint 2013 with a workflow. The workflow works fine, but when the workflow is running; the document can be updated, deleted,...
How can I lock that document when the workflow starts and unlock the document when it ends?
解決 2
I had to break the permissions from the item and at the end I reset the permissions again.
I did this with a REST request:
/ListItemAllFields/breakroleinheritance(false)
/ListItemAllFields/roleassignments/addroleassignment(principalid=1 , roledefid=2)
/resetroleinheritance
他のヒント
You need to break permissions of the item to achieve your requirement.
Step 1 :
When item is triggered for approval process, add impersonation step in your workflow and provide read permissions to all accept approvers (if required)
Step 2 :
When your item completes approval process(approved or rejected), provide back the previous permissions to the current item
Hope this solves your issue. Below are some reference links :
Lock item when approval starts
How do I stop users changing a document going through approval workflow?