In this example we will use the SendNotificationEx method to send a High Priority notification message on a workflow state change. To do this we will add code to the workflow State Actions

Example

  • Open M-Files Admin, then expand 'Connections to M-Files Servers\Local Computer\Document Vaults' 
  • Expand the desired vault and select 'Workflows' node 
  • Configure a simple workflow as shown below
  • Double-click the state on which you want to send the Notification (e.g. Listed for approval) 
  • In the 'State Properties' dialog, select the 'Actions' tab 
  • Check the 'Run Script' option, then click the 'Edit Code..' button
  • In the 'Edit VBScript code' window, add the following code


Sample VBScript

'create PentagonDOCS Notification object

Set ExDOCSNotification = GetExtensionObject("PentagonDOCS.Notifications")


'write details to the log

ExDOCSNotification.WriteLog ActivityID, "Send High Priority Notification"


'create a list of users to send to

Dim usersOrGroups : Set usersOrGroups = CreateObject("MFilesAPI.UserOrUserGroupIDs")

Dim UserID : Set UserID = CreateObject("MFilesAPI.UserOrUserGroupID")

UserID.UserOrGroupID = 1

UserID.UserOrGroupType = 1 ' User account type

usersOrGroups.add -1,UserID 'add user Id's and group ID's to the collection


'get options Object and set our options

Dim options : Set options = ExDOCSNotification.GetNotitifcationsOptionsObject()

options.MessagePriority = "HIGH"

options.template = "default"

options.SendToUsersOrUserGroups = usersOrGroups


'send the notification

ExDOCSNotification.SendNotificationEx CurrentUserId.Value, objVer, options, ActivityID