option Explicit If ObjVer.Type = 111 Then Dim PDSOPOrder, OTSOPNumberOrder, OTCommission, ValueSOPNumberOrder, CLOrder, PDSOPNumberOrder, PDCommission OTSOPNumberOrder = Vault.ObjectTypeOperations.GetObjectTypeIDByAlias("OT.SopNumberOrders") OTCommission = Vault.ObjectTypeOperations.GetObjectTypeIDByAlias("OT.Commission") PDSOPOrder = Vault.PropertyDefOperations.GetPropertyDefIDByAlias("PD.OrderNumber") CLOrder = Vault.ClassOperations.GetObjectClassIDByAlias("CL.Order") PDSOPNumberOrder = Vault.PropertyDefOperations.GetPropertyDefIDByAlias("PD.SOPNumberOrder") PDCommission = Vault.PropertyDefOperations.GetPropertyDefIDByAlias("PD.Commission") Dim PropertyValues : Set PropertyValues = Vault.ObjectPropertyOperations.GetProperties(objver) If PropertyValues.SearchForProperty(100).TypedValue.GetValueAsLookup.Item = CLOrder Then If PropertyValues.IndexOf(PDSOPOrder) <> -1 Then ValueSOPNumberOrder = PropertyValues.SearchForProperty(PDSOPOrder).TypedValue.DisplayValue If ValueSOPNumberOrder <> "" Then Dim oSC, oSCs Set oSC = CreateObject("MFilesAPI.SearchCondition") Set oSCs = CreateObject("MFilesAPI.SearchConditions") oSC.ConditionType = MFConditionTypeEqual oSC.Expression.DataStatusValueType = MFStatusTypeObjectTypeID oSC.TypedValue.SetValue MFDataTypeLookup, OTCommission oSCs.Add -1, oSC oSC.ConditionType = MFConditionTypeEqual oSC.Expression.DataStatusValueType = MFStatusTypeDeleted oSC.TypedValue.SetValue MFDataTypeBoolean, False oSCs.Add -1, oSC oSC.ConditionType = MFConditionTypeEqual oSC.Expression.DataPropertyValuePropertyDef = PDSOPNumberOrder oSC.TypedValue.SetValue MFDataTypeText, ValueSOPNumberOrder oSCs.Add -1, oSC Dim oSearchResults Set oSearchResults = Vault.ObjectSearchOperations.SearchForObjectsByConditions(oSCs, MFSearchFlagNone, False) If oSearchResults.Count > 0 Then Dim PropertyValue Set PropertyValue = CreateObject("MFilesAPI.PropertyValue") PropertyValue.PropertyDef = PDCommission For Each oSearchResults In oSearchResults PropertyValue.TypedValue.SetValue MFDataTypeMultiSelectLookup, oSearchResults.ObjVer.ID Vault.ObjectPropertyOperations.SetProperty ObjVer, PropertyValue Next End If End If End If End If End If