VBScript Variables Explained

VBScript code is edited in the Edit VBScript code window available in the following dialogs: The available variables are described in the table below.
Note: The documentation for the M-Files API is located in Start > Programs > M-Files > Documentation > M-Files API. For more information about VBScript code and M-Files API, go to www.m-files.com/api. Instructions on writing VBScript code and working with the M-Files API are available for a separate fee from M-Files customer support ([email protected]).
ActivityID
Data Type MFilesAPI.TypedValue
Mode In
Variable Use The unique ID of the operation that is being processed. Can be used for identifying which events are caused by a certain server operation.
AllowStateTransition
Data Type Boolean
Mode Out
Variable Use Can be used to allow or deny automatic state transition when running the automatic state transition script.
CurrentTransactionID
Data Type MFilesAPI.TypedValue
Mode In
Variable Use The ID of the transaction. If event handlers are executed recursively (so that executing one causes another to be executed), the ID changes on every recursion level.
CurrentUserID
Data Type MFilesAPI.Number
Mode In
Variable Use Contains the ID of the user who performed the action that triggered the script.
CurrentUserSessionInfo
Data Type MFilesAPI.SessionInfo
Mode In
Variable Use Contains information about the login session of the user who caused the operation.
DisplayID
Data Type MFilesAPI.TypedValue
Mode In
Variable Use Contains the object's unique ID. This ID is displayed to users in the property area of M-Files Desktop when the object is selected in the list. DisplayID can contain both numbers and letters. Often, DisplayID is the same as the object's internal ID whose value can be retrieved with the ObjVer variable. The internal ID can only contain numbers. DisplayID and the internal ID are usually different when the object has been imported from an external database.
FileTransferSessionID
Data Type MFilesAPI.Number
Mode In
Variable Use Contains the user-specific data transfer identifier. The data transfer identifier is created when the data transfer is being started on the server and, at the same time, the same identifier is given to the BeforeFileUpload and BeforeFileDownload event handlers. After completion of the data transfer, the same data transfer identifier will be given to the AfterFileUpload and AfterFileDownload event handlers. This way it is possible to attach the event handlers of type "Before" to the event handlers of type "After".
FileVer
Data Type MFilesAPI.FileVer
Mode In
Variable Use Contains the complete unique ID of the target file, consisting of the file ID and file version.
GetExtensionObject
Data Type (Method)
Mode N/A
Variable Use

A method for retrieving the extension object defined by the vault application.

Use: GetExtensionObject( <object name> [, application GUID]), where the part [, application GUID] is optional.

For example: Set CK = GetExtensionObject("M-Files.ComplianceKit", "{0CAC5452-631F-4646-AC95-4A06BFB8147E}")

If the application GUID has not been specified, the extension object is searched from all the applications of the vault.

Input
Data Type MFilesAPI.TypedValue
Mode In
Variable Use A client-defined parameter for the VaultExtensionMethod event handler.
LastUsed
Data Type MFilesAPI.TypedValue
Mode In
Variable Use

Available only if a customized automatic number is being calculated for a property. The value of an automatic number usually depends on the previous calculation. For example, in ordinary consecutive numbering, the automatic value is incremented by one each time. When you are setting up customized automatic numbering, the result of the previous calculation can be retrieved by using the LastUsed variable.

For example, simple automatic numbering that increments by one could be implemented with the following simple VBScript code: Output = LastUsed + 1

LoggedOutUserID
Data Type MFilesAPI.Number
Mode In
Variable Use Contains the logged out user ID after logout.
LoginAccount
Data Type MFilesAPI.LoginAccount
Mode In
Variable Use Contains the user account data in the login.
MasterTransactionID
Data Type MFilesAPI.TypedValue
Mode In
Variable Use The ID of the transaction. If event handlers are executed recursively (so that executing one causes another to be executed), this transaction ID is the ID of the first transaction.
MFScriptCancel
Data Type MFilesAPI.Number
Mode In
Variable Use

Contains the error code which is used by the scripts for displaying error messages to users. M-Files often adds detailed data to error messages; this can be prevented with the error code of the MFScriptCancel variable.

Example: Err.Raise MFScriptCancel, "This is the error message shown to the user."

NextStateID
Data Type MFilesAPI.Number
Mode Out
Variable Use During the automatic state transition, the NextStateID variable contains the ID of the state for which the automatic state transition will be performed. By changing the value of this variable, you can define the next state in the automatic state transition script. By default, the target state is the same as set in the Next State option in the user interface.
ObjectAccessControlList
Data Type MFilesAPI.ObjectAccessControlList
Mode In
Variable Use Contains the current permissions of the viewed object.
ObjID
Data Type MFilesAPI.ObjID
Mode In
Variable Use The ID of the object being processed.
ObjVer
Data Type MFilesAPI.ObjVer
Mode In
Variable Use Contains the complete unique ID of the target version, consisting of the object type ID, object internal ID, and object version.
Output
Data Type MFilesAPI.TypedValue
Mode Out
Variable Use

Available only if a customized automatic number is being calculated for a property. When VBScript code starts to run, the Output variable contains the current value of the property being calculated (but not for automatic numbering).

The main purpose of VBScript code is usually to create a new value and assign it to the Output variable, which is then stored in the object's metadata. If the VBScript code does not set the value of the Output variable, the property value in the metadata remains the same.

The value of the Output variable can, in simple cases, be set with a simple statement, for example: Output = 123

If the datatype of the value being calculated is, say, Choose from list, the SetValue method is recommended for setting the value of the Output variable (see M-Files API), for example, as follows: Output.SetValue MFDatatypeLookup, 101

ParentTransactionID
Data Type MFilesAPI.TypedValue
Mode In
Variable Use The ID of the transaction. If event handlers are executed recursively (so that executing one causes another to be executed), this transaction ID is the ID of the previous (calling) transaction.
PropertyDef
Data Type MFilesAPI.PropertyDef
Mode In
Variable Use Contains the information about the property value being calculated, such as the property value definition ID, name, and data type.
PropertyValue
Data Type MFilesAPI.PropertyValue
Mode In
Variable Use Contains a property value. Each property value is stored in the PropertyValues variable as a variable of the type PropertyValue. A certain property value can be retrieved with the SearchForProperty method.
PropertyValues
Data Type MFilesAPI.PropertyValues
Mode In
Variable Use Contains all the property values of the target version that were affected by the current action. Each property value is stored in the variable PropertyValues as a variable of the type PropertyValue. A certain property value can be retrieved with the SearchForProperty method.
RestoredVersions
Data Type MFilesAPI.IDs
Mode In
Variable Use Contains object versions of the exported object that were imported from the content package.
SavepointVariables
Data Type MFilesAPI.NamedValues
Mode In/Out
Variable Use A container for optional name-value pairs stored for the duration of a single transaction. The container automatically reverts the modifications caused by failed operations in the container.
ScheduledJob
Data Type MFilesAPI.ScheduledJob
Mode In
Variable Use Contains a description of the scheduled job which is being performed.
ScheduledJobOutputInfo
Data Type MFilesAPI.ScheduledJobOutputInfo
Mode In
Variable Use Contains information of the scheduled job result after the job has been performed.
StateID
Data Type MFilesAPI.Number
Mode In
Variable Use Contains the workflow state identifier which can be used to recognize the process state in scripts related to the workflows.
StateTransitionID
Data Type MFilesAPI.Number
Mode In
Variable Use The ID of the state transition.
TransactionCache
Data Type MFilesAPI.NamedValues
Mode In/Out
Variable Use A container for optional name-value pairs stored for the duration of a single transaction. The container retains all the modifications, even if they were caused by an operation that was later canceled due to an error.
UserAccount
Data Type MFilesAPI.UserAccount
Mode In
Variable Use Vault user information.
UserGroupAdmin
Data Type MFilesAPI.UserGroupAdmin
Mode In
Variable Use Vault user group information.
ValueListItem
Data Type MFilesAPI.ValueListItem
Mode In
Variable Use Contains the value list value which is being processed in the event handler.
Vault
Data Type MFilesAPI.Vault
Mode In
Variable Use

Represents the document vault used in running the script. With the identifier, the script is able to handle the document vault contents in the same way as is possible with the M-Files API interface. In an error situation, all changes made to the document vault through the Vault entity will be cancelled.

The use of the Vault entity with scripts entails certain limitations. The scripts cannot, through the Vault entity, change the state of the object which the script is run to. The state change refers to checking out the object, checking in the object, undoing the check-out, and deleting and destroying the object. Also, all other objects that are checked out in the script must be checked in during running of the same script.

VaultSharedVariables
Data Type MFilesAPI.NamedValues
Mode In/Out
Variable Use

A collection of named values stored in the document vault database. With the variable, the scripts can store their own values in the database so that they are also available to other scripts. The allowed data types for the named values are integer variables, Booleans, and strings.

In the following example, the value 123 is stored as a named value and the number-based calculated value is then set as the value.

VaultSharedVariables( "Message" ) = 123

Output = VaultSharedVariables( "Message" )