The M-Files Community will be updated on Tuesday, April 2, 2024 at 10:00 AM EST / 2:00 PM GMT and the update is expected to last for several hours. The site will be unavailable during this time.

This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Rollback Object to some previous version?

Hi

I can roll back objects from condition search but I'd like modify current document in workflow, but it says that code is running or similar. How to modify this to run on workflow for current object? Reason why conditions is not an option is the number of objects to modify -> Timeouts

dim DocID, DocVer, VersionNum

Set DocID = Objver.objid
DocVer = Objver.Version
VersionNum = DocVer - 2

Dim CurVersion : Set CurVersion = Vault.ObjectOperations.GetLatestObjVer( DocID, True, True)

Vault.ObjectOperations.Checkout( DocID )

Vault.ObjectOperations.Rollback DocID, VersionNum

Vault.ObjectOperations.CheckIn( DocID )

PJ

Parents
  • I think the workflow implicitly checks out the document for you, so there shouldn't be a need to do checkout - check in separately in your workflow script. Have you tried it without those operations?

  • I've tried all I can think of.

    If the code is like that

    1 Option Explicit
    2 dim DocID, DocVer, VersionNum
    3
    4 Set DocID = Objver.objid
    5 DocVer = Objver.Version
    6 VersionNum = DocVer - 2
    7
    8 Dim CurVersion : Set CurVersion = Vault.ObjectOperations.GetLatestObjVer( DocID, True, True)
    9
    10 Vault.ObjectOperations.CheckIn( CurVersion )
    11 Vault.ObjectOperations.Rollback CurVersion, VersionNum

    It gives error on line 11. "Toiminto ei ole sallittu. Komentosarjaa suoritetaan kohteelle '1222384'".

    If I comment out line 10 the error is like "Object is already Checked out"

Reply
  • I've tried all I can think of.

    If the code is like that

    1 Option Explicit
    2 dim DocID, DocVer, VersionNum
    3
    4 Set DocID = Objver.objid
    5 DocVer = Objver.Version
    6 VersionNum = DocVer - 2
    7
    8 Dim CurVersion : Set CurVersion = Vault.ObjectOperations.GetLatestObjVer( DocID, True, True)
    9
    10 Vault.ObjectOperations.CheckIn( CurVersion )
    11 Vault.ObjectOperations.Rollback CurVersion, VersionNum

    It gives error on line 11. "Toiminto ei ole sallittu. Komentosarjaa suoritetaan kohteelle '1222384'".

    If I comment out line 10 the error is like "Object is already Checked out"

Children
  • I would be surprised if there's a way to do this within a synchronous process, such as an event handler or state action.  Rolling back the object creates a new version, but the system hasn't finished processing the previous version, so it'll fail.

    With the VAF and some sort of asynchronous process, yes, as you could fire the update after the current version has been checked in.  But not whilst it's being modified.

  • So impossible case again. I solved it by doing conditons that finds only few at a time. Then automatic transition that runs it for every document with on error resume 'cos it could find itself that would fail.