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

In workflow, check if property has more than 1 entry

I'm creating a workflow.  The first two states are Draft and Reviewer(s).  The Reviewer(s) property is multi-select.  I require the user of the workflow to enter at least two Reviewer(s).   I set the property pre-condition to check if Reviewer(s) > 1.  However, this doesn't seem to work.  I guess the ">" operator is used for numbers only, and not quantity.

Is there a way to accomplish this without creating two different properties?

Parents
  • You need a small script (or VAF application) for this which you would use as the precondition via Advanced conditions (VBScript). The script would take the Reviewer(s) property, count the number of values in it and return true/false depending on the result.

  • Something like this could work, please test before applying to a production environment:

    Option Explicit
    
    ' Get the property by its alias.
    Dim iPDProperty : iPDProperty = GetPropertyIDByAlias("PD.Reviewers")
    
    ' Get the collection of property values, this is where you'll find the field.
    Dim PropertyValues : Set PropertyValues = Vault.ObjectPropertyOperations.GetProperties(ObjVer, False)
    
    ' Does the property exist on the metadata card?
    If PropertyValues.IndexOf(iPDProperty) <> -1 Then
    	' Property exists on the metadata card.  Good to go.
    
    	Dim propertyValue : Set propertyValue = PropertyValues.SearchForProperty(iPDProperty)
    	If (propertyValue.TypedValue.GetValueAsLookups.Count < 2) Then 
    		Err.Raise MFScriptCancel, "At least two reviewers required"
    	End If
    Else
    	Err.Raise MFScriptCancel, "Reviewers not found"
    End If
    
    '##### Common Functions #####
    Function GetPropertyIDByAlias(alias)
    	Dim iID
    	iID = Vault.PropertyDefOperations.GetPropertyDefIDByAlias(alias)
    	If iID = -1 Then
    		Err.Raise MFScriptCancel, "Property Definition not found in vault by specified alias of '" & alias & "'"
    	End If
    	GetPropertyIDByAlias = iID
    End Function

Reply
  • Something like this could work, please test before applying to a production environment:

    Option Explicit
    
    ' Get the property by its alias.
    Dim iPDProperty : iPDProperty = GetPropertyIDByAlias("PD.Reviewers")
    
    ' Get the collection of property values, this is where you'll find the field.
    Dim PropertyValues : Set PropertyValues = Vault.ObjectPropertyOperations.GetProperties(ObjVer, False)
    
    ' Does the property exist on the metadata card?
    If PropertyValues.IndexOf(iPDProperty) <> -1 Then
    	' Property exists on the metadata card.  Good to go.
    
    	Dim propertyValue : Set propertyValue = PropertyValues.SearchForProperty(iPDProperty)
    	If (propertyValue.TypedValue.GetValueAsLookups.Count < 2) Then 
    		Err.Raise MFScriptCancel, "At least two reviewers required"
    	End If
    Else
    	Err.Raise MFScriptCancel, "Reviewers not found"
    End If
    
    '##### Common Functions #####
    Function GetPropertyIDByAlias(alias)
    	Dim iID
    	iID = Vault.PropertyDefOperations.GetPropertyDefIDByAlias(alias)
    	If iID = -1 Then
    		Err.Raise MFScriptCancel, "Property Definition not found in vault by specified alias of '" & alias & "'"
    	End If
    	GetPropertyIDByAlias = iID
    End Function

Children
No Data