Article Details
Id:10912
Product:finPOWER Connect
Type:FIX
Version:1.06.07
Opened:13/02/2013
Closed:14/02/2013
Released:27/03/2013
Job: J011114
Breaking Change

Workflows; Workflow Actions wizard not using 'GenerateMessage' event on Email and SMS Documents

The Workflow Actions wizard was not calling the 'GenerateMessage' event for Email and SMS Documents.

This functionality has now been implemented meaning that a Document's Script can generate the Message and optionally override the SMS Phone Number/ Email Address in the wizard.

The following example shows how to override the message for an SMS Document. Note that this Document may be published from the Account Document wizard or via actioning a Workflow item in which case the Source object passed to the Script will be a finAccount object.

' Handle Events
Select Case eventId
  Case "GenerateMessage"
    If TypeOf source Is List(Of finTaskManagerWorkflow) Then
      ' From Workflow Actions wizard
      returnvalues.SetString("Message", "Workflow Actions wizard message")
    ElseIf TypeOf source Is finAccount Then
      ' From Account/ Workflow item
      returnvalues.SetString("Message", "Account/ Workflow message")
    End If
    
    ' Override SMS Phone Number
    'returnValues.SetString("phone", "sms1; sms2")
      
    ' NOTE: EventArgs.GetString("Message") contains the template message as defined on the Document
End Select

The next example demonstrates overriding the message and subject for an Email Document.

' Handle Events
Select Case eventId
  Case "GenerateMessage"
    If TypeOf source Is List(Of finTaskManagerWorkflow) Then
      ' From Workflow Actions wizard
      returnvalues.SetString("Message", "Workflow Actions wizard message")
      returnvalues.SetString("Subject", "Workflow Actions wizard subject")
    ElseIf TypeOf source Is finAccount Then
      ' From Account/ Workflow item
      returnvalues.SetString("Message", "Account/ Workflow message")
      returnvalues.SetString("Subject", "Account/ Workflow subject")
    End If

    ' Optionally, set the 'To', 'CC' and 'BCC' fields on the 'Create Document' form for Email and 'Phone' for SMS
    'returnValues.SetString("to", "email1; email2")
    'returnValues.SetString("cc", "ccemail1; email2")
    'returnValues.SetString("bcc", "bccemail1; email2")

    ' NOTE: EventArgs.GetString("Message") and EventArgs.GetString("Subject") contain the template message and subject as defined on the Document
End Select

NOTE: This is flagged as a breaking change since some Scripts may rely on receiving a finAccount object whereas this change means that when run via the Workflow Actions wizard, the Script will receive a List(Of finTaskManagerWorkflow) object.