Available VBScript Variables

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 M-Files API documentation is available online: M-Files API. For more information about using VBScript in M-Files, see the How do I write VBScript code for M-Files purposes? tutorial.
Variable Data type Mode Use
ActivityID MFilesAPI.TypedValue In 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 Boolean Out Can be used to allow or deny automatic state transition when running the automatic state transition script.
CurrentTransactionID MFilesAPI.TypedValue In 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 MFilesAPI.Number In Contains the ID of the user who performed the action that triggered the script.
CurrentUserSessionInfo MFilesAPI.SessionInfo In Contains information about the login session of the user who caused the operation.
DisplayID MFilesAPI.TypedValue In 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 MFilesAPI.Number In 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 MFilesAPI.FileVer In Contains the complete unique ID of the target file, consisting of the file ID and file version.
GetExtensionObject (method) N/A 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.

GroupID MFilesAPI.Number In The ID of the target user group.
Input MFilesAPI.TypedValue In A client-defined parameter for the VaultExtensionMethod event handler.
IsCancellable MFilesAPI.BooleanValue In Normally, scripts can cancel a server operation and revert the associated transaction by raising an error in the script. The IsCancellable variable specifies whether the script is allowed do this.

If the value of the variable is false, M-Files Server will ignore any errors raised in the script. If the script raises an error while the value of the variable is false, however, an error is written to the Windows event log and all the changes made via the script are reverted. The server operation then proceeds to completion.

LastUsed MFilesAPI.TypedValue In 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 MFilesAPI.Number In Contains the logged out user ID after logout.
LoginAccount MFilesAPI.LoginAccount In Contains the user account data in the login.
MasterTransactionID MFilesAPI.TypedValue In 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.
MemberID MFilesAPI.Number In The ID of the member who is added to or removed from a user group. The value is negative if the member is a user group.
MFScriptCancel MFilesAPI.Number In 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 MFilesAPI.Number Out 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 MFilesAPI.ObjectAccessControlList In Contains the current permissions of the viewed object.
ObjID MFilesAPI.ObjID In The ID of the object being processed.
ObjVer MFilesAPI.ObjVer In Contains the complete unique ID of the target version, consisting of the object type ID, object internal ID, and object version.
Output MFilesAPI.TypedValue Out 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 data type 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 MFilesAPI.TypedValue In 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 MFilesAPI.PropertyDef In Contains the information about the property value being calculated, such as the property value definition ID, name, and data type.
PropertyValue MFilesAPI.PropertyValue In 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 MFilesAPI.PropertyValues In 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.
Note: Some property definitions are not shown when using the PropertyValues variable in scripts (see Property definitions not shown for scripts).
RestoredVersions MFilesAPI.IDs In Contains object versions of the exported object that were imported from the content package.
SavepointVariables MFilesAPI.NamedValues In/Out 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 MFilesAPI.ScheduledJob In Contains a description of the scheduled job which is being performed.
ScheduledJobOutputInfo MFilesAPI.ScheduledJobOutputInfo In Contains information of the scheduled job result after the job has been performed.
StateID MFilesAPI.Number In Contains the workflow state identifier which can be used to recognize the process state in scripts related to the workflows.
StateTransitionID MFilesAPI.Number In The ID of the state transition.
TransactionCache MFilesAPI.NamedValues In/Out 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 MFilesAPI.UserAccount In Vault user information.
UserGroupAdmin MFilesAPI.UserGroupAdmin In Vault user group information.
ValueListItem MFilesAPI.ValueListItem In Contains the value list value which is being processed in the event handler.
Vault MFilesAPI.Vault In 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 MFilesAPI.NamedValues In/Out 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" )

View MFilesAPI.View In Contains the view which is being processed in the event handler.

Property definitions not shown for scripts

The property definitions listed in the following table are not shown by using the PropertyValues variable in scripts:

Name ID
Status changed 24
Single file 22
Deleted 27
Deleted by 28
Comment 33
Version label 29
Size on server (this version) 30
Size on server (all versions) 31
Marked for archiving 32
Collection members (documents) 46
Collection members (document collections) 47
Class groups 101
Assignment description 41
Deadline 42
Monitored by 43
Assigned to 44
Marked as complete by 45
Marked as rejected by 97
Workflow Assignment 79
Accessed by me 81
Favorite view 82
Object changed 89
Permissions changed 90
Version label changed 91
Version comment changed 92
Deletion status changed 93
Conflict resolved 96
Object changed for export 105
Object version changed for export 106

For example, the following piece of script results in a "not found" error:

Dim DeadlineValue
DeadlineValue = PropertyValues.SearchForProperty(42).TypedValue.DisplayValue
Tip: You can use the GetProperties method to get all the properties of a specific object.