You are viewing limited content. For full access, please sign in.

Question

Question

Can LF workflow revert back a document to previous version and discard the changes?

asked on July 24, 2019

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.

 

0 0

Replies

replied on July 24, 2019

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.

1 0
replied on July 25, 2019

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.   

 

 

 

 

  

0 0
replied on July 25, 2019

What if there are multiple users with pending changes to the same document?

1 0
replied on July 25, 2019

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)      

0 0
replied on July 25, 2019

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.

1 0
replied on July 26, 2019

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.    

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.