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

How to create an Obj inside a particular workflow

Hello..

My goal is to create an obj that belongs to a particular workflow.

At this moment I can create an obj with all the metadata properties I need.. However when tryng to add the obj to the workflow I faiced a wall.

My current approach was to treat the workflow name as regular property setting the respective value /  ID and creating the obj.

However, the approach did not worked

I would like to know if I am in the right path.

Thank you ver much,

Best regards,

  • Depends a bit on how and where you create the object. From the way you ask it seems like you attempt to do it via scripting or something of that sort. If that is the case you need to get the workflow ID and insert it as a lookup into property 38. You should also get the first workflow state ID and insert that as a lookup into property 39.

    Here is a script that you can use as inspiration:

    '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("<your workflow alias>")
    Dim iWFnewState : iWFnewState = Vault.WorkflowOperations.GetWorkflowStateIDbyAlias("<your 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