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

Workflow state precondidion setting with Advanced Conditions (VBScript)

Hello
I am truing to set up a workflow, were one of the States has to have a precondition with multiple metadata properties. In the object metadata card I have an Engineering Responsible and a Project Manager, Next state should be allowed only if one or both fields are filled. When using Property condition definition it works on AND principle, so I can set if both are filled.
I would like to try to set the condition using the Advanced Conditions(VBScript) option. How do I set the output? What property o variable I should set to allow or block the state transition?
So far I have this code, but what should be set if the condition is met?
Option Explicit

' Get Engineering responsible.
Dim szEngineeringResponsible
szEngineeringResponsible = PropertyValues.SearchForProperty( 1644 ).TypedValue.DisplayValue
if szEngineeringResponsible <> null then

???????

end if
 
Parents
  • Thank you very much, that helped! I still could not set the Advanced conditions, but I created a buffer workload state and added a script to the Actions->Run script option. In this case user can save all the data to the document and metadata card and move the document to the next workflow state. That will trigger the script, that checks if the requested fields are filled and then ether shows an error message and moves the document back to the previous state, or if everything is OK then it moves it to the next workflow state.
    Option Explicit

    Dim iWFState ' Define Workflow state variable.
    Dim szTrigger ' Define Trigger variable.

    ' Get Engineering responsible.
    Dim szEngineeringResponsible
    szEngineeringResponsible = PropertyValues.SearchForProperty( 1644 ).TypedValue.DisplayValue

    ' Get Purchasing responsible.
    Dim szPurchasingResponsible
    szPurchasingResponsible = PropertyValues.SearchForProperty( 1645 ).TypedValue.DisplayValue

    'Logic test if the fileds are not empty then set next state if they are set previous state.

    if len(szEngineeringResponsible) <> 0 or len(szPurchasingResponsible) <> 0 then

    iWFState = Vault.WorkflowOperations.GetWorkflowStateIDbyAlias("WF.Next state")
    PropertyValues.SearchForProperty(39).TypedValue.SetValue MFDataTypeLookup, iWFState

    else

    iWFState = Vault.WorkflowOperations.GetWorkflowStateIDbyAlias("WF.Returntopreviousstate")
    PropertyValues.SearchForProperty(39).TypedValue.SetValue MFDataTypeLookup, iWFState
    Err.Raise MFScriptCancel, "At least one Responsible must be specified before moving to the next state"
    end if


    'Save the changed propertyvalues to the object
    Vault.ObjectPropertyOperations.SetAllProperties ObjVer, true, PropertyValues



    I found one more way of doing it with out scripting at all, but it is not so elegant, but might come in handy for someone else.
    I created a new property in the Metadata card. Named it "Responsible field" in the Automatic Values tab, set Simple concatenating of properties and added both place holders of the Engineering and PM responsible properties there. Then I set that property as hidden so users can not see it.
    If Engineering responsible or PM responsible or both are filled the new property also gets a value, if not it also stays empty.
    Then in the workflow state preconditions I set the "Responsible field" as "is not empty".
    This way if the automatic value is filled then the transition can move to the next state if not users get an error message that "Responsible field" can not be empty.

Reply
  • Thank you very much, that helped! I still could not set the Advanced conditions, but I created a buffer workload state and added a script to the Actions->Run script option. In this case user can save all the data to the document and metadata card and move the document to the next workflow state. That will trigger the script, that checks if the requested fields are filled and then ether shows an error message and moves the document back to the previous state, or if everything is OK then it moves it to the next workflow state.
    Option Explicit

    Dim iWFState ' Define Workflow state variable.
    Dim szTrigger ' Define Trigger variable.

    ' Get Engineering responsible.
    Dim szEngineeringResponsible
    szEngineeringResponsible = PropertyValues.SearchForProperty( 1644 ).TypedValue.DisplayValue

    ' Get Purchasing responsible.
    Dim szPurchasingResponsible
    szPurchasingResponsible = PropertyValues.SearchForProperty( 1645 ).TypedValue.DisplayValue

    'Logic test if the fileds are not empty then set next state if they are set previous state.

    if len(szEngineeringResponsible) <> 0 or len(szPurchasingResponsible) <> 0 then

    iWFState = Vault.WorkflowOperations.GetWorkflowStateIDbyAlias("WF.Next state")
    PropertyValues.SearchForProperty(39).TypedValue.SetValue MFDataTypeLookup, iWFState

    else

    iWFState = Vault.WorkflowOperations.GetWorkflowStateIDbyAlias("WF.Returntopreviousstate")
    PropertyValues.SearchForProperty(39).TypedValue.SetValue MFDataTypeLookup, iWFState
    Err.Raise MFScriptCancel, "At least one Responsible must be specified before moving to the next state"
    end if


    'Save the changed propertyvalues to the object
    Vault.ObjectPropertyOperations.SetAllProperties ObjVer, true, PropertyValues



    I found one more way of doing it with out scripting at all, but it is not so elegant, but might come in handy for someone else.
    I created a new property in the Metadata card. Named it "Responsible field" in the Automatic Values tab, set Simple concatenating of properties and added both place holders of the Engineering and PM responsible properties there. Then I set that property as hidden so users can not see it.
    If Engineering responsible or PM responsible or both are filled the new property also gets a value, if not it also stays empty.
    Then in the workflow state preconditions I set the "Responsible field" as "is not empty".
    This way if the automatic value is filled then the transition can move to the next state if not users get an error message that "Responsible field" can not be empty.

Children
No Data