M-Files API 23.11.13135.0
SetProperty Method
VaultObjectPropertyOperations Object : SetProperty Method
The object version that identifies the object.
The property value to update.
Description
Sets the specified property value of the specified object version.
Syntax
Visual Basic
Public Function SetProperty( _
   ByVal ObjVer As ObjVer, _
   ByVal PropertyValue As PropertyValue _
) As ObjectVersionAndProperties
Parameters
ObjVer
The object version that identifies the object.
PropertyValue
The property value to update.
Remarks

This method cannot be used to change the class of an object. Use SetAllProperties instead if this is needed.

Note

In case this method modifies the permissions of the object through pseudo users or automatic components it might be possible that the object won't be visible to the user after the operation has completed.

Example
' 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)
Sub SetRelationshipToSpecificVersion( _
        ByVal vault As MFilesAPI.Vault, _
        ByVal parentObject As MFilesAPI.ObjectVersion, _
        ByVal relatedObject As MFilesAPI.ObjectVersion)

    ' Create lookup to a specific version.
    Dim lookup As New MFilesAPI.Lookup
    lookup.Item = relatedObject.ObjVer.ID
    lookup.Version = relatedObject.ObjVer.Version

    ' Create multi-select lookup structure.
    Dim lookups As New MFilesAPI.Lookups
    lookups.Add(-1, lookup)

    ' Create property value that includes the previously created
    ' lookup and specifies the property definition.
    Dim propertyValue As New MFilesAPI.PropertyValue
    propertyValue.TypedValue.SetValueToMultiSelectLookup(lookups)
    propertyValue.PropertyDef = 1234

    ' Set property for the object.
    vault.ObjectPropertyOperations.SetProperty(parentObject.ObjVer, propertyValue)

End Sub
See Also

VaultObjectPropertyOperations Object  | VaultObjectPropertyOperations Members