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

Automate change of WF to new WF based on specific state

We have a Workflow that is being replaced by a new one.  All documents in the Client with the existing workflow applied need to change over to the new WF based on a specific state.  I wanted to automatic the change to a new Workflow and its corresponding state.  Is there a way to achieve this?

When the existing WF is 'effective' (pdf) as soon as the permitted user applies a 'new revision' a script creates a new document and using a copy from the effective version (prior to the pdf conversion) and sets the state to 'draft'.

Once the document is in draft at this point I wanted to change the workflow over to the new one and apply the new state as we have thousands of documents this will apply to.

I have tried to use Hierarchy Manager but it doesn't seem to work so my only other thought was the possibility of updating the script to changing the WF but not sure if this would work.  

Any ideas greatly appreciated.

Parents
  • This script can be used with a few changes to define the new workflow and state.

    'General script for changing workflow and or state as State Action
    '2021.07.09 Karl Lausten
    Option Explicit
    'clear State
    Dim oStProperty : set oStProperty = CreateObject("MFilesAPI.PropertyValue")
    oStProperty.PropertyDef = 39
    oStProperty.TypedValue.SetValue MFDataTypeLookup, Null
    Vault.ObjectPropertyOperations.SetProperty ObjVer, oStProperty
    'prepare WF
    Dim oWFProperty : set oWFProperty = CreateObject("MFilesAPI.PropertyValue")
    oWFProperty.PropertyDef = 38
    'determine future workflow and state (if conditions are required, insert relevant "if" statements)
    Dim iWFnew : iWFnew = Vault.WorkflowOperations.GetWorkflowIDbyAlias("<new workflow alias>")
    Dim iWFnewState : iWFnewState = Vault.WorkflowOperations.GetWorkflowStateIDbyAlias("<new state alias>")
    'set new workflow and state
    oWFProperty.TypedValue.SetValue MFDataTypeLookup, iWFnew
    Vault.ObjectPropertyOperations.SetProperty ObjVer, oWFProperty
    oStProperty.TypedValue.SetValue MFDataTypeLookup, iWFnewState
    Vault.ObjectPropertyOperations.SetProperty ObjVer, oStProperty
    

  • Thank you very much I will give that a try

Reply Children
No Data