Frequently Asked Questions
Frequently Asked Questions
How to automatically change object workflow to another
Posted by Sakari Heinonen (M-Files) on 30 September 2019 11:36 AM

1     Overview

You cannot set a new workflow to an object by using "Set properties" in a workflow state, but you can change the workflow to another workflow and state automatically when it reaches the final state via small workflow action script.

2     Solution

Add the script below to the state properties of the final state, choose "Actions" and check "Run script", then click "Edit code"

Paste this code to the editor, note that you will need to change "NewState" and "NewWorkflow" IDs (112 and 105 used here) to match the IDs used in your vault. You can find the Workflow ID in the Workflows editor and the state ID in the Workflow properties.

Dim NewState : NewState = 112 ' Workflow State ID, check from Workflow States value list
Dim NewWorkflow : NewWorkflow = 105 ' Workflow ID, check from Workflows value list
Dim oPropVal: Set oPropVal = CreateObject("MFilesAPI.PropertyValue")
oPropVal.PropertyDef = 39 ' Workflow state build-in property
oPropVal.TypedValue.SetValue MFDatatypeLookup, NewState
Vault.ObjectPropertyOperations.SetProperty ObjVer, oPropVal
oPropVal.PropertyDef = 38 ' Workflow build-in property
oPropVal.TypedValue.SetValue MFDatatypeLookup, NewWorkflow
Vault.ObjectPropertyOperations.SetProperty ObjVer, oPropVal

(0 vote(s))
This article was helpful
This article was not helpful

Help Desk Software by Kayako case