AddNotification

You can use the AddNotification function to create user-facing notification messages displayed in the Optiva user interface during the workflow actions or object operations. This function creates entries in the notification table that reference predefined message codes to communicate important information, warnings, or errors to the developers.

When to use

You can use this function when:

  • The data validation has failed, and users need information about the validation error.
  • A warning condition requires user attention but is not an error.
  • An operation is completed successfully.
  • The information or fields are missing.

When not to use

You cannot use this function for technical details, logging, debugging, or when there is no active user to act on the notification.

Syntax

long AddNotification(string messageCode, string propertyName, int severity, string objSymbol = "", string objectKey = "", string detailCode = "", string rowkey = "");

Parameters

Parameter Type Required Description
objSymbol string Optional

The symbol of the object.

Note: You can use empty quotation marks ("") for the current workflow symbol.
objKey string Optional

The key of the object.

Note: You can use empty quotation marks ("") for the current workflow symbol.
messageCode string Yes The reference code for a message code defined in the Optiva Message Code feature.
Note: This code must exist in the application and enable multi-language definitions.
propertyname string Yes

The name of the field or property associated with the notification.

Note: The function associates the notification with the specified field in the user interface.
severity int Yes

The severity level of the notification. Possible values:

  • 0 - Informational messages, confirmations
  • 1 – Warning, cautions, non-critical issues
  • 2 –Errors, validation failures, critical issues
Note: The function throws an ArgumentException for any other value.
detailCode string Optional

The detail code used to return the new row. Possible values:

  • HEADER
  • INGR
  • TPALL
  • CONTEXT
  • BYPROD
  • REFS
Note: The default value is HEADER if the parameter is blank or empty.
rowkey string Optional Reserved for future use. This parameter is currently not functional. Pass an empty string.

Return Value

A unique identifier ID for the notification entry is created in the notification table. You can use the ID to track or reference the created notification.

Note: The return value must be captured to track, log, or reference a specific notification entry.

Prerequisites

  • The specified message code must exist in the Optiva message code feature.
    Note: Undefined message codes are not displayed or cause an error.
  • The severity parameter must be 0, 1, or 2.
    Note: The function throws an ArgumentException for any other value, and a notification is not created.

Examples

Example 1

You can use AddNotification to attach a user-facing notification to one or more object fields (for example, DESCRIPTION, CLASS, APPROVALCODE).

If you add the code to a workflow action, notifications are set for the description, class and approval code fields. If one or more fields do not exist on a particular symbol, an error message is displayed.

For example, the message codes in a system:

  • C_INFO01 - informational text (For example, "This is informational.").
  • C_WARN01 - warning text (For example, "Please review the Class value."). C_ERR01 - error text (For example, "Approval Code.").
using System; 
using Formation.Shared.Defs; 
class ActionScript : FcProcFuncSetEventWF{ 
public long wf_start() 
    { 
 AddNotification("C_INFO01", "DESCRIPTION", 0); 
        AddNotification("C_WARN01", "CLASS", 1); 
        AddNotification("C_ERR01", "APPROVALCODE", 2); 
        return 111L; 
    } 
}