If approval denied, I need workflow to revert back to previous version of the document and delete the most recent version (changes). Is this possible via WF? Any suggestions is appreciated.
If approval denied, I need workflow to revert back to previous version of the document and delete the most recent version (changes). Is this possible via WF? Any suggestions is appreciated.
You can do it with an SDK Script activity.
Something like this will revert the document and delete the version that was replaced.
// get document and current version DocumentInfo doc = (DocumentInfo)this.BoundEntryInfo; int current = doc.CurrentVersion; int previous = current - 1; // revert document doc.Revert(previous); // refresh document info doc.Refresh(true); // get and delete removed version DocumentVersion rejected = new DocumentVersion(doc.Id,current,RASession); rejected.Delete("Changes rejected");
However, there is a lot to consider with reverting and deleting and you should probably use more robust code than what it shown in the example to handle errors and such.
If you revert, it still creates a new version. For example, if I revert from version 2 to version 1, I end up with version 3, which will be identical to version 1.
If you then delete version 2, the version history would show versions 1 and 3.
Additionally, if you have a deleted version in there, you'll need to adjust the code to account for that.
For example, if you then tried to revert version 3 using the code above, you would get an error because version 2 no longer exists.
Thanks Jason
I am not a developer and it seems there are many thing to be considered. I may have to change the process.
The idea is , a user opens the document>>>>>>>>>> Does changes>>>>>>When its saved, Notification goes to owner for approval on change>>>> If owner denies we need to revert back previous version.
What if there are multiple users with pending changes to the same document?
That is a great questions? Haven't considered, we can either check out the doc and check in after changes doc or field values changes. Revert back if denied.
Or
The safe way would be to get approval before any changes to the document. Submit the document via forms saving in temp location until it get approved than ingest it using workflow (I am not sure if we can increment the version this way)
Right, but you check it out, make changes and check it back in. While it's waiting for approval, another user can check it out and modify it. The approver would either not get a change to reject it because the second user still has it checked out OR, if the second user is done with his changes, the approver would have to look at versions and see there were 2 people modifying it.
How about if we limit people to view only or export out to the content of the Folder. Every change uploaded via forms process to a Temp folder (the name sequentially number), If approved the document will get to right folder - and merge with current version adding new version number. Yes, I am not sure how we can handle the situation when multiple people have the folder open and work on original document.