Hello community,
I'm trying to find the parent of a value list item using VBScript.
Dim SearchForValue: SearchForValue = "Apple"
Dim oSc : Set oSc = CreateObject("MFilesAPI.SearchCondition")
Dim oScs : Set oScs = CreateObject("MFilesAPI.SearchConditions")
oSc.ConditionType = MFConditionType.MFConditionTypeStartsWith
oSc.Expression.SetValueListItemExpression MFValueListItemPropertyDef.MFValueListItemPropertyDefName, MFParentChildBehavior.MFParentChildBehaviorNone
oSc.TypedValue.SetValue MFDataType.MFDatatypeText, SearchForValue
oScs.Add -1, oSc
Dim ValueList: ValueList = 125 ' the ID of the value list for fruits
'Perform search.
Dim oRes
Dim oResults : Set oResults = vault.ValueListItemOperations.SearchForValueListItemsEx(ValueList,oScs,false,MFExternalDBRefreshType.MFExternalDBRefreshTypeNone,true)
'Result:
If oResults.Count = 1 Then ' Only try to write if there is one result
Dim IDOfResult, IDOfParent
Set oRes = oResults.Item(1)
IDOfResult = oRes.ObjVer.ID
IDOfParent = oRes.ObjVer.ParentID
End If
I'm getting a Type mismatch error: 'Expression.SetValueListItemExpression', I'm not even getting to the 'IDOfParent = oRes.ObjVer.ParentID' part.
What am I doing wrong?