M-Files API 23.11.13135.0
VaultObjectPropertyOperations Object
Members 
Description
A group of methods for updating and modifying the properties of an object.
Public Methods
Marks the assignment as approved or rejected by the logged-in user.
Marks the assignment as approved or rejected by the specified user.
Clears the archiving marker of the object.
Creates properties based on the given file information.
Generates the automatic permissions components from the specifies property values.
Gets all the properties of the specified object version.
Gets the properties of the specified object version as XML.
Gets the properties of the specified object version for display purposes.
Gets the direct and indirect properties of the specified object version for the purpose of synchronizing file content with current metadata.
Gets the direct and indirect properties of the specified object version to synchronize the file content with the current metadata.
Gets the direct and indirect properties of the specified object version to synchronize the file content with the current metadata.
Gets the properties of multiple objects.
Gets the properties of the specified object versions for display purposes.
Gets all the properties of the specified object version with icon clues.
Gets the properties of multiple objects with icon clues.
Gets the specified property value of the specified object version.
Gets the version comment of the specified object.
Gets the version comment history of the specified object.
Gets the workflow of the specified object.
Marks the assignment as completed by the logged-in user.
Marks the assignment as completed by the specified user.
Marks the object for archiving.
Removes the specified property value from the specified object version.
Sets all the properties of the specified object.
Sets all the properties of the specified object.
Sets all the properties and permissions of the specified object.
Sets all the properties and permissions of the specified object.
Sets the creation info of the specified object. Returns the properties of the specified object after modification.
Sets the last modified info of the specified object version. Returns the properties of the specified object after modification.
Sets all the properties of the specified object version.
Sets the specified properties of the specified object version.
Sets the properties of multiple objects.
Sets all the properties and permissions of the specified object version.
Sets all the properties and permissions of the specified object version.
Sets the specified property value of the specified object version.
Sets the version comment for the specified object.
Sets the workflow for the specified object.
Sets the workflow for the specified object.
Sets the workflow state transition for the specified object.
Sets the workflow state transition for the specified object with an electronic signature.
Example
This method group interface can be accessed via the Vault object.
' Initialize the API and connect to a vault.
Dim oVault As MFilesAPI.Vault
' ...

' We are searching for the document with ID 123.
Dim iDocumentId As Integer
iDocumentId = 123

' Initialize an ObjID object.
Dim oObjId As New MFilesAPI.ObjID
oObjId.SetIDs(MFilesAPI.MFBuiltInObjectType.MFBuiltInObjectTypeDocument, iDocumentId)

' Invoke the search operation.
Dim oResult As MFilesAPI.ObjectVersionAndProperties
oResult = oVault.ObjectOperations.GetLatestObjectVersionAndProperties(oObjId, True)

' Resolve the value of the "Name or title" property.
Dim oPropertyValue As MFilesAPI.PropertyValue
oPropertyValue = oResult.Properties.SearchForProperty( _
    MFilesAPI.MFBuiltInPropertyDef.MFBuiltInPropertyDefNameOrTitle)

' Output the document title.
Call Console.WriteLine("Title: " + oPropertyValue.TypedValue.DisplayValue)
Call Console.WriteLine("Other properties and their values:")

' List all the other properties and their values.
For Each oPropertyValue2 As MFilesAPI.PropertyValue In oResult.Properties

    If oPropertyValue2.PropertyDef <> MFilesAPI.MFBuiltInPropertyDef.MFBuiltInPropertyDefNameOrTitle Then

        ' Find the property definition for the property.
        Dim oPropertyDef As MFilesAPI.PropertyDef
        oPropertyDef = oVault.PropertyDefOperations.GetPropertyDef(oPropertyValue2.PropertyDef)

        ' Output the name and the value of the property.
        Call Console.WriteLine("   " + oPropertyDef.Name + ": " + oPropertyValue2.TypedValue.DisplayValue)

    End If

Next

' Initialize the API and connect to a vault.
Dim oVault As MFilesAPI.Vault
' ...

' We are searching for the document with ID 123.
Dim iDocumentId As Integer
iDocumentId = 123

' Initialize an ObjID object for the search.
Dim oObjId As New MFilesAPI.ObjID
oObjId.SetIDs(MFilesAPI.MFBuiltInObjectType.MFBuiltInObjectTypeDocument, iDocumentId)

' Get object version properties.
Dim oObjectVersionAndProperties As MFilesAPI.ObjectVersionAndProperties = Nothing
oObjectVersionAndProperties = oVault.ObjectOperations.GetLatestObjectVersionAndProperties(oObjID, True)

' Create new property value.
Dim oPropertyValue As MFilesAPI.PropertyValue = New MFilesAPI.PropertyValue
oPropertyValue.PropertyDef = 1096  ' In this case, represents the "Effective through" property
oPropertyValue.TypedValue.SetValue(MFilesAPI.MFDataType.MFDatatypeDate, DateSerial(2015, 1, 1))

' Modify the object. The object needs to be in checked out state.
oVault.ObjectPropertyOperations.SetProperty(oObjectVersionAndProperties.ObjVer, oPropertyValue)
' Placeholder for all the property definitions in the system.
Private garrPropertyDefs As MFilesAPI.PropertyDefs
' Placeholder for all the value lists in the system.
Private garrValueLists As MFilesAPI.ObjTypes

Sub SetPropertiesForAnObject

    ' Initialize the API and connect to a vault.
    Dim oVault As MFilesAPI.Vault
    ' ...

    ' Ensure that we are aware of all the property definitions and value lists available. This needs to be done only once.
    LoadPropertyDefs(oVault)
    LoadValueLists(oVault)

    ' We are searching for the document with ID 123.
    Dim iDocumentId As Integer
    iDocumentId = 123

    ' Initialize an ObjID object for the search.
    Dim oObjId As New MFilesAPI.ObjID
    oObjId.SetIDs(MFilesAPI.MFBuiltInObjectType.MFBuiltInObjectTypeDocument, iDocumentId)

    ' Check out the object first. We assume that initially the object is checked in.
    Dim oObjectVersionCheckedOut As MFilesAPI.ObjectVersion
    oObjectVersionCheckedOut = oVault.ObjectOperations.CheckOut(oObjID)

    ' Resolve the property definition IDs.
    Dim iPropDefProject = MF_FindPropertyDefID(oVault, "Project")
    Dim iPropDefJobTitle = MF_FindPropertyDefID(oVault, "Job title")

    ' Resolve the IDs of the project lookup value.
    Dim iProjectValueList = MF_FindValueListID(oVault, "Projects")
    Dim iProjectValueListItem = MF_FindValueListItemID(oVault, iProjectValueList, "Philo District Redevelopment")

    ' Container for the added and/or modified properties.
    Dim oPropertyValues As New MFilesAPI.PropertyValues
    
    ' Initialize a "Project" property value.
    Dim oPropertyValue1 As New MFilesAPI.PropertyValue
    oPropertyValue1.PropertyDef = iPropDefProject
    oPropertyValue1.TypedValue.SetValue(MFilesAPI.MFDataType.MFDatatypeMultiSelectLookup, iProjectValueListItem)
    oPropertyValues.Add(-1, oPropertyValue1)

    ' Initialize a "Job title" property value.
    Dim oPropertyValue2 As New MFilesAPI.PropertyValue
    oPropertyValue2.PropertyDef = iPropDefJobTitle
    oPropertyValue2.TypedValue.SetValue(MFilesAPI.MFDataType.MFDatatypeText, "My job title")
    oPropertyValues.Add(-1, oPropertyValue2)

    ' Set the properties.
    oVault.ObjectPropertyOperations.SetProperties(oObjectVersionCheckedOut.ObjVer, oPropertyValues)

    ' Finally, we must check in the changes.
    oVault.ObjectOperations.CheckIn(oObjectVersionCheckedOut.ObjVer)

 End Sub
 
 ' Helper method to load all the property definitions in the system.
Sub LoadPropertyDefs(ByRef oVault As MFilesAPI.Vault)
    garrPropertyDefs = oVault.PropertyDefOperations.GetPropertyDefs
End Sub

' Helper method to load all the value lists in the system.
Sub LoadValueLists(ByRef oVault As MFilesAPI.Vault)
    garrValueLists = oVault.ValueListOperations.GetValueLists
End Sub

' Helper function to find the property definition ID by the property definition name.
Function MF_FindPropertyDefID( _
            ByRef oVault As MFilesAPI.Vault, _
            ByVal szPropDefName As String) As Integer

    MF_FindPropertyDefID = -1
    Dim oPropDef As MFilesAPI.PropertyDef
    For i = 1 To garrPropertyDefs.Count
        oPropDef = garrPropertyDefs.Item(i)
        If oPropDef.Name = szPropDefName Then
            MF_FindPropertyDefID = oPropDef.ID
        End If
    Next
End Function

' Helper function to find the value list ID by the value list name.
Function MF_FindValueListID( _
            ByRef oVault As MFilesAPI.Vault, _
            ByVal szValueListName As String) As Integer

    MF_FindValueListID = -1
    Dim oValList As MFilesAPI.ObjType
    For i = 1 To garrValueLists.Count
        oValList = garrValueLists.Item(i)
        If oValList.NamePlural = szValueListName Then
            MF_FindValueListID = oValList.ID
        End If
    Next
End Function

' Helper function to find the value list item ID by the value list item name.
Function MF_FindValueListItemID( _
            ByRef oVault As MFilesAPI.Vault, _
            ByVal iValueListID As Integer, _
            ByVal szValueListItemName As String) As Integer

    ' Set the search conditions for the value list item.
    Dim oScValueListItem As New MFilesAPI.SearchCondition
    oScValueListItem.Expression.SetValueListItemExpression( _
        MFilesAPI.MFValueListItemPropertyDef.MFValueListItemPropertyDefName, _
        MFilesAPI.MFParentChildBehavior.MFParentChildBehaviorNone)
    oScValueListItem.ConditionType = MFilesAPI.MFConditionType.MFConditionTypeEqual
    oScValueListItem.TypedValue.SetValue(MFilesAPI.MFDataType.MFDatatypeText, szValueListItemName)
    Dim arrSearchConditions As New MFilesAPI.SearchConditions
    arrSearchConditions.Add(-1, oScValueListItem)
    ' Search for the value list item.
    Dim results As MFilesAPI.ValueListItemSearchResults
    results = oVault.ValueListItemOperations.SearchForValueListItemsEx(iValueListID, arrSearchConditions)
    If results.Count > 0 Then
        ' Found.
        MF_FindValueListItemID = results(1).ID
    Else
        ' Not found.
        MF_FindValueListItemID = -1
    End If
End Function

See Also

VaultObjectPropertyOperations Members