VBScript Variables Explained

VBScript code is edited in the Edit VBScript code window. The following variables can be used in VBScript code:

AllowStateTransition

Variable name: AllowStateTransition

Variable data type: Boolean (see M-Files API)

Variable use:

The AllowStateTransition variable can be used to allow or deny automatic state transition when running the automatic state transition script. If the variable's Boolean is "true" after completion of the script, the object will be moved to the object state specified by the NextStateID variable.

CurrentUserID

Variable name: CurrentUserID

Variable data type: Number (see M-Files API)

Variable use:

The CurrentUserID variable contains the ID of the user who performed the action that triggered the script.

DisplayID

Variable name: DisplayID

Variable data type: TypedValue (see M-Files API)

Variable use:

The DisplayID variable 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

Variable name: FileTransferSessionID

Variable data type: Number (see M-Files API)

Variable use:

The FileTransferSessionID variable 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

Variable name: FileVer

Variable data type: FileVer (see M-Files API)

Variable use:

The FileVer variable contains the complete unique ID of the target file, consisting of the file ID and file version.

LoggedOutUserID

Variable name: LoggedOutUserID

Variable data type: Number (see M-Files API)

Variable use:

The LoggedOutUserID variable contains the logged out user ID after logout.

LoginAccount

Variable name: LoginAccount

Variable data type: LoginAccount (see M-Files API)

Variable use:

The LoginAccount variable contains the user account data in the login.

MFScriptCancel

Variable name: MFScriptCancel

Variable data type: Number (see M-Files API)

Variable use:

The MFScriptCancel variable contains the error code which is used by the scripts to display 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

Variable name: NextStateID

Variable data type: Number (see M-Files API)

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

Variable name: ObjectAccessControlList

Variable data type: AccessControlList (see M-Files API)

Variable use:

The ObjectAccessControlList variable contains the current permissions of the viewed object.

ObjVer

Variable name: ObjVer

Variable data type: ObjVer (see M-Files API)

Variable use:

The ObjVer variable contains the complete unique ID of the target version, consisting of the object type ID, object internal ID, and object version.

PropertyDef

Variable name: PropertyDef

Variable data type: PropertyDef (see M-Files API)

Variable use:

The PropertyDef variable contains the information about the property value being calculated, such as the property value definition ID, name, and data type.

PropertyValue

Variable name: PropertyValue

Variable data type: PropertyValue (see M-Files API)

Variable use:

The PropertyValue variable contains the viewed property value. When verifying the correctness of the property value, the incorrect property value can be notified to the user as in the following example: Err.Raise MFScriptCancel, "The value you entered is not valid."

PropertyValues

Variable name: PropertyValues

Variable data type: PropertyValues (see M-Files API)

Variable use:

The PropertyValues variable contains all current property values for the target version (such as Name, Project, and Customer). Each property value is stored in PropertyValues as a variable of the type PropertyValue.

A certain property value can be retrieved with the SearchForProperty method. For more information, refer to the M-Files API documentation.

RestoredVersions

Variable name: RestoredVersions

Variable data type: IDs (see M-Files API)

Variable use:

The RestoredVersions variable contains object versions of the exported object that were imported from the content package.

ScheduledJob

Variable name: ScheduledJob

Variable data type: ScheduledJob (see M-Files API)

Variable use:

The ScheduledJob variable contains a description of the scheduled job which is being performed.

ScheduledJobOutputInfo

Variable name: ScheduledJobOutputInfo

Variable data type: ScheduledJobOutputInfo (see M-Files API)

Variable use:

The ScheduledJobOutputInfo variable contains information of the scheduled job result after the job has been performed.

StateID

Variable name: StateID

Variable data type: Number (see M-Files API)

Variable use:

The StateID variable contains the workflow state identifier which can be used to recognize the process state in scripts related to the workflows.

ValueListItem

Variable name: ValueListItem

Variable data type: ValueListItem (see M-Files API)

Variable use:

The ValueListItem variable contains the value list value which is being processed in the event handler.

Vault

Variable name: Vault

Variable data type: Vault (see M-Files API)

Variable use:

The Vault variable represents the document vault which is 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 Vault entity with scripts entails certain limitations. The scripts cannot, through Vault entity, change the state of the object which the script is run to. The state change refers to checking the object out, checking the object in, 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

Variable name: VaultSharedVariables

Variable data type: NamedValues (see M-Files API)

Variable use:

The VaultSharedVariables variable is a collection of named values which are 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, 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" )

Note: The administrator must already be familiar to VBScript programming language. Instructions for writing the VBScript code is not included in M-Files or M-Files API documentation. The documentation for the M-Files API is installed in the folder Start > Programs > M-Files > Documentation > M-Files API. For more information about VBScript code and M-Files API, contact [email protected]. Instructions on writing VBScript code and working with the M-Files API are available from the M-Files technical support staff for a separate fee.