Notify
You can use the Notify function to send email notifications to Optiva users, groups, or roles by using predefined email templates. This function enables automated notifications within workflows, supporting dynamic content through template parameters and flexible recipient targeting.
When to use
You can use this function to:
- Send automated notifications during workflow execution.
- Send approval request notifications to users, groups, or roles.
- Notify users about status changes, rejections, or other important events.
When not to use
You cannot use this function when:
- The email notification requires attachments or complex multi-part MIME messages.
- The required email template is not configured in the system.
Syntax
long Notify(string addressee, string template, int mode, int addresseeType, params string[] args)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| addressee | string | Yes | The recipient of the notification.
Note: Can be a specific user code, group name, or role name depending on addresseeType.
|
| template | string | Yes | The code of the Email Template form to be used. This function defines the message format, subject, and content.
Note: Must match an existing template in the system.
|
| mode | int | Yes | The delivery method.
Note: By default the value is 1 (External SMTP Server - Microsoft, UNIX). Other values are typically ignored.
|
| addresseeType | int | Optional | A numeric code that tells the system what type of recipient you are sending message to. Possible values:
|
| args | string[] | Optional | The variable-length parameter array for dynamic template content. The parameters are referenced in templates as [%1], [%2], etc., where the number corresponds to the parameter position. |
Working with notifications
Using the Email Template form, create the text for the email message.
To construct a general message that references Optiva objects specific to a workflow, precede the objects with % and enclose the object in brackets.
| Token | Description | Example Use |
|---|---|---|
| [%1] | The first custom parameter into the message is inserted. | The custom data passed to notification. |
| [%ACTIONCODE] | The current action code into the message is inserted. | The action that triggered the notification. |
| [%SOURCEUSER] | The current user who performed the action is inserted. | The user who executed the workflow action. |
| [%STARTUSER] | The user who started the workflow is inserted. | The original workflow initiator. |
| [%TASKUSER] | The username of the task user who caused the message to be sent is inserted. | The user assigned to the task. |
| [%WIPALLUSERS] | All users, members of groups, and members of roles connected to the workflow are inserted. | The complete list of all related users. |
| [%WIPGROUPS] | The members of all groups connected to the workflow are inserted. | All the group members. |
| [%WIPID] | The workflow ID into the message is inserted. | The unique workflow identifier. |
| [%WIPLINEID] | The line number for the workflow is inserted. | The current workflow line/step. |
| [%WIPROLES] | The members of all roles connected to the workflow are inserted. | All the role members. |
| [%WIPUSERS] | All users connected to the workflow are inserted. | The direct user assignments. |
Return Value
The application returns a value one (1) if the operation is successful or else failure.
Impact
- Sends an email messages to the specified recipients.
- Queues email delivery through the configured SMTP server.
Prerequisites
- The SMTP server must be properly configured.
- The specified user, group, or role must exist in the system.
- Users must have valid email addresses configured.
- The template parameters must match the expected template format.
Examples
- Example 1
-
This example determines to notify the user (FSI) about the references removal.
int rtnval = Workflow.RemoveReferences("", "", refSymbol, refObject); if (rtnval >= 0) { MessageList("References is removed for " + refSymbol + " with reference object " + refObject); long rc = Notify("FSI", "REFERENCE_REMOVAL_NOTIFY", 1, 0); }
- Arguments
-
addressee : FSI
template : REFERENCE_REMOVAL_NOTIFY
mode : 1
addresseeType : 0
- Example 2
-
In the template code, the appropriate parameters replace the arguments enclosed in brackets when the message is sent.
The text in the template code reads:
Workflow [%WIPID] Action [%ACTIONCODE] has been rejected. Reason: Formula [%1] belonging to class: [%2] has been rejected by [%TASKUSER].
The workflow script is:
object oClass = ObjProperty("CLASS", "", ""); long lNotify = Notify("RL_ADMIN", "REJECT", 1, 1, Context._OBJECTKEY, oClass);
The notification message reads:
From: <address> Sent: <date> To: <address> Subject: Workflow 2464 Action LAB_MANAGER has been rejected. Reason: Formula PIZZA_SAUCE\003 belonging to class: CLASS A = Finished Product has been rejected by JOE_SMITH.
Tokens
[%WIPID] : 2464
[%ACTIONCODE] : LAB_MANAGER
[%TASKUSER] : JOE_SMITH
[%1] : PIZZA_SAUCE\003
[%2] : CLASS A = Finished Product