VBScript code is edited in the Edit VBScript code window. The following variables can be used in VBScript code:
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.
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.
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.
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'.
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.
Variable name: LoggedOutUserID
Variable data type: Number (see M-Files API)
Variable use:
The LoggedOutUserID variable contains the logged out user ID after logout.
Variable name: LoginAccount
Variable data type: LoginAccount (see M-Files API)
Variable use:
The LoginAccount variable contains the user account data in the login.
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."
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.
Variable name: ObjectAccessControlList
Variable data type: AccessControlList (see M-Files API)
Variable use:
The ObjectAccessControlList variable contains the current permissions of the viewed object.
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.
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.
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."
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.
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.
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.
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.
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.
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.
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.
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" )