M-Files API 22.6.11519.0
CreateNewObject Method
VaultObjectOperations Object : CreateNewObject Method
The object type for the new object as the object type ID number.
The collection of the property values for the new object.

The collection of the source files for the new object.

In scripting languages, a specific null value (e.g., Nothing in VBScript) should be used to indicate the default value.

The access control list for the new object.

In scripting languages, a specific null value (e.g., Nothing in VBScript) should be used to indicate the default value.

Description
Creates a new object based on the specified properties and source files.
Syntax
Visual Basic
Public Function CreateNewObject( _
   ByVal ObjectType As Long, _
   ByVal PropertyValues As PropertyValues, _
   Optional ByVal SourceObjectFiles As SourceObjectFiles = 0, _
   Optional ByVal AccessControlList As AccessControlList = 0 _
) As ObjectVersionAndProperties
Parameters
ObjectType
The object type for the new object as the object type ID number.
PropertyValues
The collection of the property values for the new object.
SourceObjectFiles

The collection of the source files for the new object.

In scripting languages, a specific null value (e.g., Nothing in VBScript) should be used to indicate the default value.

AccessControlList

The access control list for the new object.

In scripting languages, a specific null value (e.g., Nothing in VBScript) should be used to indicate the default value.

Return Type
The ObjectVersionAndProperties object that contains information on the new object.
Remarks
At a minimum, the property values collection needs to contain property values and other required property definitions for the object class.
Example
' Create property definitions
Dim oPropertyValues As MFilesAPI.PropertyValues = New MFilesAPI.PropertyValues

' Add 'Name and Title' property by creating a new PropertyValue object.
' The PropertyValue object encapsulates the metadata information (PropertyDef)
' and the actual value (TypedValue).
Dim oPropertyValue1 As MFilesAPI.PropertyValue = New MFilesAPI.PropertyValue
oPropertyValue1.PropertyDef = MFilesAPI.MFBuiltInPropertyDef.MFBuiltInPropertyDefNameOrTitle
oPropertyValue1.TypedValue.SetValue(MFilesAPI.MFDataType.MFDatatypeText, "DemoObject")
oPropertyValues.Add(0, oPropertyValue1)

' Add 'Class' property
Dim oPropertyValue2 As MFilesAPI.PropertyValue = New MFilesAPI.PropertyValue
oPropertyValue2.PropertyDef = MFilesAPI.MFBuiltInPropertyDef.MFBuiltInPropertyDefClass
oPropertyValue2.TypedValue.SetValue(MFilesAPI.MFDataType.MFDatatypeLookup, _
                                    MFilesAPI.MFBuiltInDocumentClass.MFBuiltInDocumentClassOtherDocument)
oPropertyValues.Add(1, oPropertyValue2)

' Add 'Single file' property
Dim oPropertyValue3 As MFilesAPI.PropertyValue = New MFilesAPI.PropertyValue
oPropertyValue3.PropertyDef = MFilesAPI.MFBuiltInPropertyDef.MFBuiltInPropertyDefSingleFileObject
oPropertyValue3.TypedValue.SetValue(MFilesAPI.MFDataType.MFDatatypeBoolean, True)
oPropertyValues.Add(2, oPropertyValue3)

' Add source file.
Dim oSourceFiles As MFilesAPI.SourceObjectFiles = New MFilesAPI.SourceObjectFiles
Dim oSourceFile1 As MFilesAPI.SourceObjectFile = New MFilesAPI.SourceObjectFile
oSourceFile1.SourceFilePath = "c:\demo.txt"
oSourceFile1.Title = "demo"
oSourceFile1.Extension = "txt"
oSourceFiles.Add(0, oSourceFile1)

' Create new object.
Dim oObjectVersionAndProperties As MFilesAPI.ObjectVersionAndProperties
oObjectVersionAndProperties = m_vault.ObjectOperations.CreateNewObject( _
                                    MFilesAPI.MFBuiltInObjectType.MFBuiltInObjectTypeDocument, _
                                    oPropertyValues, oSourceFiles)

' Check in the newly created object.
m_vault.ObjectOperations.CheckIn(oObjectVersionAndProperties.ObjVer)
See Also

VaultObjectOperations Object  | VaultObjectOperations Members