Article Details
Id:10914
Product:finPOWER Connect
Type:FIX
Version:1.06.07
Opened:14/02/2013
Closed:11/03/2013
Released:27/03/2013
Job: J011117

Document 'GenerateMessage' Script event cannot access Parameters

A Document's 'GenerateMessage' Script event cannot access Parameters.

The 'GenerateMessage' event may wish to use the Parameters entered to generate the message or subject (for Email type Documents).

This has been updated in the following places:

  • Workflow Actions wizard for Email and SMS type Documents
  • Create Document wizard (e.g., Send Document from the Accounts form)

The Parameters are passed to the Script as an ISParameters type object meaning that the Script can modify the Parameters (e.g., update or add parameters) if required. These Parameters are stored on the Document Log.

The following example assumes that the Document has a Text type Parameter with a name of 'FriendlyName'. This can be used when generating the message and also updated by the Script if required.

Select Case eventId
  Case "GenerateMessage"
    Dim Params As ISParameters = DirectCast(parameters, ISParameters)

    'Params.SetString("FriendlyName", "modified name")

    If TypeOf source Is List(Of finTaskManagerWorkflow) Then
      ' From Workflow Actions wizard
      returnvalues.SetString("Message", "Workflow Actions wizard message: " & Params.GetString("FriendlyName"))
    ElseIf TypeOf source Is finAccount Then
      ' From Account/ Workflow item
      returnvalues.SetString("Message", "Account/ Workflow message: " & Params.GetString("FriendlyName"))
    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

NOTE: The parameters argument is defined as type 'Object' for the Main function. This is because cetain Document types and events receive an ISParameters object and others receive an ISKeyValueList value. The 'GenerateMessage' event will always receive an ISParameters type object hence we must cast it to the correct type (i.e., the Params variable).

Documents generated via a process that does not involve User entry of Document Parameters (e.g., Account Type Rules, actioning a Workflow Item) will receive an empty ISParameters object.