M-Files API 22.6.11519.0
Lookup Object
Members 
Description
Lookup specifies a single lookup value.
Public Methods
Creates a copy of the object.
Copies the content to this object from another object.
Copies the lookup as an ObjVer structure.
Gets the formatted display value.
Specifies whether this lookup reference is based on unmanaged data.
Sets the lookup value to refer to the latest version.
Public Properties
Specifies whether the item is deleted.
The display ID of the item. This may differ from the numeric internal ID.
Specifies whether the display ID is available.
Display value. If not set the value of the lookup may appear as '(hidden)' in M-Files UI.
The ID of the external repository icon.
The external repository name of the object.
The external repository identifier of the object.
Hidden.
Item.
The item GUID as a string.
Object flags.
Object type.
Version. -1 always refers to the latest version of the lookup item.
The object version.
Remarks

The lookup class represents a reference to the object version or to the value list item. Lookup objects can be read from the TypedValue object if it has a lookup or multi-select lookup type.

In order to refer an object version, three pieces of information are needed: object type, object ID and object version. The lookup item contains the latter two items. To follow the reference, you need to know the object type for the target item.

A reference to a value list item is similar to that with an object version reference, except that the version part is not used. The lookup item contains the value list item ID, and the referee needs to know which value list is being referred to.

In some cases, the lookup target is a known, built-in value list (like the classes value list or the users value list). Elsewhere the target object type is explicitly expressed. For example, if the lookup originates from the PropertyValue object, the corresponding PropertyDef object contains the object type ID in the ValueList property.

 

 

Lookup reference as a property value (highlighted with the green rectangle) as seen in M-Files Desktop. The lookup refers to a Customer object type.

Example
' Identify the object and property.
Dim oObjVer As MFilesAPI.ObjVer
Dim iPropertyId As Integer
'...

' Get the value of property.
Dim oPropertyValues As MFilesAPI.PropertyValues = oVault.ObjectPropertyOperations.GetProperties(oObjVer)
Dim oPropertyValue As MFilesAPI.PropertyValue = oPropertyValues.SearchForProperty(iPropertyId)

' Resolve the target item for lookup reference.
If oPropertyValue.TypedValue.DataType = MFilesAPI.MFDataType.MFDatatypeLookup Then

    ' Get the value as lookup reference.
    Dim oLookUpRef As MFilesAPI.Lookup = oPropertyValue.TypedValue.GetValueAsLookup()

    ' Resolve the target object type for the property value.
    Dim oPropertyDef As MFilesAPI.PropertyDef = oVault.PropertyDefOperations.GetPropertyDef(oPropertyValue.PropertyDef)
    Dim oValListObjType As MFilesAPI.ObjType = oVvault.ValueListOperations.GetValueList(oPropertyDef.ValueList)

    ' Separate handling for object version and value list item references.
    If (oValListObjType.RealObjectType) Then

        ' Target type is a object type.
        ' Create object version identifier based on the reference.
        Dim oObjVerLocal As MFilesAPI.ObjVer = New MFilesAPI.ObjVer
        oObjVerLocal.SetIDs(oValListObjType.ID, oLookUpRef.Item, oLookUpRef.Version)

        ' Get the referred object version.
        Dim oObjVerAndProp As MFilesAPI.ObjectVersionAndProperties = _
            oVault.ObjectOperations.GetObjectVersionAndProperties(oObjVerLocal, False)
        ' ...

    Else

        ' Target is a value list item.

        Dim oValueListItems As MFilesAPI.ValueListItems = oVault.ValueListItemOperations.GetValueListItems(oValListObjType.ID)
        ' Search the value list item by id (oLookUpRef.Item)
        ' ...
    End If

End If
See Also

Lookup Members