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

Write mutli select property from value list

HI all

I have a Workflow that Documents move through, with a few States such as 'Placeholder', 'Approved', 'Accepted', 'Handed Over'

I have a Property called 'Document States' which is 'Choose from list "Workflow States" (multi select)'

I want to write the current workflow State to the Document, whenever it moves through the workflow, so the property will gradually hold a list of all the states that a document has been in 

So if the doc started as Placeholder state, then 'Document States' property should show just that one

If the doc then moves through Placeholder, Approved, Accepted, then 'Document States' property should show all 3 of those states

If the doc moves back to Placeholder state, the 'Document States' property should still show the same 3 as before (it shouldn't show Placeholder twice)

I'm then going to hide that property, but allow users to search by it, so they can use Search Filters on the property to find a document that was previously 'Accepted', even if it is currently back in the 'Placeholder' state

I've been trying VB script in the workflow, I know I likely need SetValueToMultiSelectLookup but don't know really how to tackle it

Its possibly similar to this: community.m-files.com/.../7719 and/or this community.m-files.com/.../10343

Could any one help, or suggest a better alternative approach to achieve the same thing?

Many thanks

  • Got it working

    'Add the current Workflow State to a list of previous States
    'get the current Workflow State as a single lookup
    Dim ilookup : set ilookup = PropertyValues.SearchForProperty(39).TypedValue.GetValueAsLookup  'property 39 = Workflow State
    
    'get the current Doc States list as a multi lookup
    pDocStates = vault.PropertyDefOperations.GetPropertyDefIDByAlias("H.Property.DocumentStates")
    Dim ilookups : set ilookups = PropertyValues.SearchForProperty(pDocStates).TypedValue.GetValueAsLookups
    
    'Check if the State is already in the list, or if it's unique
    Dim IsUnique 
    IsUnique = 1
    Dim lookup2 : Set lookup2 = CreateObject("MFilesAPI.Lookup")
    
    For Each lookup2 In ilookups
        If lookup2.DisplayValue = iLookup.DisplayValue then IsUnique = 0
    Next
    
    If IsUnique = 1 then
        'add the single lookup to the lookups
        Call ilookups.Add(-1, ilookup)
    End If
    
    
    'Create property value that includes the lookup, and specifies the property definition
    Dim sPropertyValue : Set sPropertyValue = CreateObject("MfilesAPI.PropertyValue")
    sPropertyValue.TypedValue.SetValueToMultiSelectLookup(ilookups)
    sPropertyValue.PropertyDef = pDocStates
    
    ' Set property for the object.
    Call vault.ObjectPropertyOperations.SetProperty(ObjVer, sPropertyValue)