Using multi-select property in VBS

Hey guys, I was wondering if anybody could help me out on how to use the "TypedValue.GetValueAsLookups" function.
Here's an explanation on what I want to do.

I have a object called "Shipment", this object has these metadata:
Shipment ID (Integer)
Orders (Multi-select)

And then there's the "Order" object, with the following metadata:
Order ID (Integer)
Product (Text)
Planned shipment (Text)

What I want to do is fill out the metadata "Planned shipment" with the shipment ID everytime a user selects the order from the shipment metadata.
The customer needs this to keep track on which orders that is already has a planned shipment/planned to be shipped.

I have managed to do this with a single select property, but i have no idea how to set this up with a multi-select property.

Parents
  • As a result, there are two approaches that can be used:

    - It is simpler to take all values as comma-separated text:

    Dim oPropVals: Set oPropVals = CreateObject("MFilesApi.PropertyValues")
    Set oPropVals = Vault.ObjectPropertyOperations.GetProperties(ObjVer)
    
    Dim iPDPropmultiselectlookup: iPDPropmultiselectlookup = Vault.PropertyDefOperations.GetPropertyDefIDByAlias("PD.Propmultiselectlookup")
    
    '--------------------------------------------------------------------------
    'Get Multi-Select Lookup as Text (Comma separated)
    szPDPropmultiselectlookup = oPropVals.SearchForProperty(iPDPropmultiselectlookup).GetValueAsLocalizedText()
    
    Err.Raise MFScriptCancel, szPDPropmultiselectlookup
    

    - It is more complicated to take it as a collection from Lookup and make a loop on it. Something similar to:

    Dim oPropVals: Set oPropVals = CreateObject("MFilesApi.PropertyValues")
    Set oPropVals = Vault.ObjectPropertyOperations.GetProperties(ObjVer)
    
    Dim iPDPropmultiselectlookup: iPDPropmultiselectlookup = Vault.PropertyDefOperations.GetPropertyDefIDByAlias("PD.Propmultiselectlookup")
    'Get Collection of Lookup from MultiSelect Lookup as object
    Set oPDPropmultiselectlookup = oPropVals.SearchForProperty( iPDPropmultiselectlookup ).TypedValue.GetValueAsLookups()
    
    For Each Lookup In oPDPropmultiselectlookup
    ‘Get Lookup as ID
    intYourVariable = Lookup.Item
    .
    .
    .
    
    ‘or  Get Lookup value as text for example
    
    szYourVariable = szYourVariable  & Lookup.TypedValue.DisplayValue & vbCrLf
    .
    .
    .
    Next
    

Reply
  • As a result, there are two approaches that can be used:

    - It is simpler to take all values as comma-separated text:

    Dim oPropVals: Set oPropVals = CreateObject("MFilesApi.PropertyValues")
    Set oPropVals = Vault.ObjectPropertyOperations.GetProperties(ObjVer)
    
    Dim iPDPropmultiselectlookup: iPDPropmultiselectlookup = Vault.PropertyDefOperations.GetPropertyDefIDByAlias("PD.Propmultiselectlookup")
    
    '--------------------------------------------------------------------------
    'Get Multi-Select Lookup as Text (Comma separated)
    szPDPropmultiselectlookup = oPropVals.SearchForProperty(iPDPropmultiselectlookup).GetValueAsLocalizedText()
    
    Err.Raise MFScriptCancel, szPDPropmultiselectlookup
    

    - It is more complicated to take it as a collection from Lookup and make a loop on it. Something similar to:

    Dim oPropVals: Set oPropVals = CreateObject("MFilesApi.PropertyValues")
    Set oPropVals = Vault.ObjectPropertyOperations.GetProperties(ObjVer)
    
    Dim iPDPropmultiselectlookup: iPDPropmultiselectlookup = Vault.PropertyDefOperations.GetPropertyDefIDByAlias("PD.Propmultiselectlookup")
    'Get Collection of Lookup from MultiSelect Lookup as object
    Set oPDPropmultiselectlookup = oPropVals.SearchForProperty( iPDPropmultiselectlookup ).TypedValue.GetValueAsLookups()
    
    For Each Lookup In oPDPropmultiselectlookup
    ‘Get Lookup as ID
    intYourVariable = Lookup.Item
    .
    .
    .
    
    ‘or  Get Lookup value as text for example
    
    szYourVariable = szYourVariable  & Lookup.TypedValue.DisplayValue & vbCrLf
    .
    .
    .
    Next
    

Children
No Data