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

Search Multi Property by alias to get their ID

Hi all,

I am trying to set (flag) a property (called attached) within object class to yes (true). I do have a vbscript that works (within workflow state) but only for single properties list. I don't know how to make it work for MULTI properties list. Is there a way i can loop between all individual objects by Alias on the list (that i have added on the form) and set their attached property to true?


option explicit

'Define variables
Dim titleTypedValue
Dim oPropVal: Set oPropVal = CreateObject("MFilesAPI.PropertyValue")
Dim oProp: Set oProp = vault.PropertyDefOperations
Dim oPropValsCurrent: Set oPropValsCurrent = CreateObject("MFilesAPI.PropertyValues")
Dim IsAttached
Dim Ref
Dim Prop

'Get ID of Property
Set Ref = SearchForObject("Milestone", 1)

'Call "ATTACHTED" property and get latest version of property
set IsAttached = vault.ObjectPropertyOperations.GetProperties (Ref.ObjVer, true)

'Set "ATTACHTED" Property value to true (Yes)
oPropVal.PropertyDef = oProp.GetPropertyDefIDByAlias("Attached")

oPropVal.TypedValue.SetValue MFDatatypeBoolean, true
oPropValsCurrent.Add -1, oPropVal

'Apply the new properties value
Vault.ObjectPropertyOperations.SetProperties Ref.ObjVer, oPropValsCurrent


'********************************************************************************************************************
'Search For Object method
function SearchForObject(PropertyID, Index)

Dim oPropertyValsSearch: set oPropertyValsSearch = vault.ObjectPropertyOperations.GetProperties (Objver, true)
Dim EmpName
Dim titleProperty
titleProperty = 1055

EmpName = oPropertyValsSearch.SearchForPropertyByAlias(vault, PropertyID , true).Value.DisplayValue


' Find the title property of the current object.
Dim titleSearch
Set titleSearch = CreateObject("MFilesAPI.SearchCondition")
Dim titleExpression
Set titleExpression = CreateObject("MFilesAPI.Expression")
titleExpression.SetPropertyValueExpression titleproperty, 0, Nothing

Dim titleTypedValue
Set titleTypedValue = CreateObject("MFilesAPI.TypedValue")
titleTypedValue.SetValue MFDatatypeText ,EmpName
titleSearch.Set titleExpression, MFConditiontypeEqual, titleTypedValue

Dim SearchResults
Set SearchResults = Vault.ObjectSearchOperations.SearchForObjectsByCondition(titleSearch, false)

Dim oObjID: set oObjID = SearchResults.Item(Index)

set SearchForObject = oObjID

end function
Parents
  • Yes correct, my workflows is on object called "contract", the other object type is Milestone, multi property is Milestones" and the property within his class that i am trying to set is to Yes is "Attachted_Milestone". I've done some testing with your code however i was unable to make it work, I believe I might be missing something. Since I'm getting "Unknown property definition "-1".
    that is caused by this Line: Vault.ObjectPropertyOperations.SetProperties oObjVer, oPropValsCurrent

    Any idea what I am doing wrong?

    My code:

    Dim iOTChild : iOTChild = Vault.ObjectTypeOperations.GetObjectTypeIDByAlias("Milestone") 'The other object type
    Dim iPDSiblings : iPDSiblings = Vault.PropertyDefOperations.GetPropertyDefIDByAlias("Milestones") 'The other object type multi property
    Dim oSibling : set oSibling = CreateObject("MFilesAPI.Lookup")
    Dim oSiblings : set oSiblings = PropertyValues.SearchForProperty(iPDSiblings).TypedValue.GetValueAsLookups()
    Dim oObjVer, oObjVerProps
    Dim oObjID: set oObjID = CreateObject("MFilesAPI.ObjID")

    'Added these three variables
    Dim IsAttached
    Dim oPropVal: Set oPropVal = CreateObject("MFilesAPI.PropertyValue")
    Dim oPropValsCurrent: Set oPropValsCurrent = CreateObject("MFilesAPI.PropertyValues")

    For Each oSibling in oSiblings
    oObjID.SetIDs iOTChild, oSibling.Item

    set oObjVer = vault.ObjectOperations.GetLatestObjVer(oObjID,False,True)
    set oObjVerProps = vault.ObjectOperations.GetObjectVersionAndProperties(oObjVer, True)
    'Insert your code to set the flag property here.

    'Added my code for flaging the boolean property
    'Set "ATTACHTED MILESTONE" Property value to true (Yes)
    oPropVal.PropertyDef = Vault.PropertyDefOperations.GetPropertyDefIDByAlias("Attached_Milestone")
    oPropVal.TypedValue.SetValue MFDatatypeBoolean, true
    oPropValsCurrent.Add -1, oPropVal

    'Apply the new properties value
    Vault.ObjectPropertyOperations.SetProperties oObjVer, oPropValsCurrent

    Next
Reply
  • Yes correct, my workflows is on object called "contract", the other object type is Milestone, multi property is Milestones" and the property within his class that i am trying to set is to Yes is "Attachted_Milestone". I've done some testing with your code however i was unable to make it work, I believe I might be missing something. Since I'm getting "Unknown property definition "-1".
    that is caused by this Line: Vault.ObjectPropertyOperations.SetProperties oObjVer, oPropValsCurrent

    Any idea what I am doing wrong?

    My code:

    Dim iOTChild : iOTChild = Vault.ObjectTypeOperations.GetObjectTypeIDByAlias("Milestone") 'The other object type
    Dim iPDSiblings : iPDSiblings = Vault.PropertyDefOperations.GetPropertyDefIDByAlias("Milestones") 'The other object type multi property
    Dim oSibling : set oSibling = CreateObject("MFilesAPI.Lookup")
    Dim oSiblings : set oSiblings = PropertyValues.SearchForProperty(iPDSiblings).TypedValue.GetValueAsLookups()
    Dim oObjVer, oObjVerProps
    Dim oObjID: set oObjID = CreateObject("MFilesAPI.ObjID")

    'Added these three variables
    Dim IsAttached
    Dim oPropVal: Set oPropVal = CreateObject("MFilesAPI.PropertyValue")
    Dim oPropValsCurrent: Set oPropValsCurrent = CreateObject("MFilesAPI.PropertyValues")

    For Each oSibling in oSiblings
    oObjID.SetIDs iOTChild, oSibling.Item

    set oObjVer = vault.ObjectOperations.GetLatestObjVer(oObjID,False,True)
    set oObjVerProps = vault.ObjectOperations.GetObjectVersionAndProperties(oObjVer, True)
    'Insert your code to set the flag property here.

    'Added my code for flaging the boolean property
    'Set "ATTACHTED MILESTONE" Property value to true (Yes)
    oPropVal.PropertyDef = Vault.PropertyDefOperations.GetPropertyDefIDByAlias("Attached_Milestone")
    oPropVal.TypedValue.SetValue MFDatatypeBoolean, true
    oPropValsCurrent.Add -1, oPropVal

    'Apply the new properties value
    Vault.ObjectPropertyOperations.SetProperties oObjVer, oPropValsCurrent

    Next
Children
No Data