4.3.3.2 Examples of workflow definitions including notifications
This section shows an example of how to define notifications to be sent at any point in the workflow.
When the notification "type" is set to "onDemand", notifications can be sent at any timing specified in the workflow.
You can embed values from workflow fields or parameters configured in the Workflow YAML file into the notification content as follows:
- Use .GetValue
For a list of available values, see "(Table) Object fields that can be used in Notification". - Use the Ops I component "oi.notify"
You can embed parameters defined in the Workflow YAML file. You can dynamically change the message content and recipients in the workflow definition.
Examples of definitions for the Workflow YAML file and the Notification YAML file are shown below.
For details about the Workflow YAML definition, see “Workflow”; for the Ops I component “oi.notify”, see “(Table) List of actions (provided Ops I components)”.
For details on the YAML definitions for Notification and Notifier, see “Notification, Notifier”.
Notes
The value of "notification" defined in the Workflow YAML file must match the value of "name" defined in the Notification YAML file. Additionally, when using the Ops I component "oi.notify", configure the Notification YAML file as follows:
- Set "event.resource" to "workflow".
- Set "event.type" to "onDemand".
- Do not specify "conditions".
- When embedding the "oi.notify" parameter defined in the Workflow YAML file into the Notification YAML file, specify it as follows:
{{ .OINotify.params.key }}
[Use case: Defining the message title and part of the content in the Workflow YAML file]
Define the content of the re-application notification in the Workflow YAML file, and create a Notification YAML file based on that content.
<Example of a tasks definition in the Workflow YAML>
notify_vm_wf_02:
action: oi.notify
input:
notification: lend_request_notification
params:
type: Re-application
document: Items to be passed on
next:
- when: <% succeeded() %>
do: next_step
- when: <% failed() %>
do: fail
<Example of a definition in the Notification YAML>
apiVersion: 1.0
kind: notification
## Meta data
type: resource
name: lend_request_notification
label: Loan request notification
description: This is the YAML definition for sending a loan request notification to the assignee.
## Notification contents
event:
resource: workflow
type: onDemand
notifications:
- message:
title: {{ .OINotify.params.type }} notification regarding a VM loan
body: |
A {{ .OINotify.params.type }} notification regarding a VM loan has arrived. Please review {{ .OINotify.params.document }} and take the necessary action.
Request date and time: {{ .GetValue ".Context.createdOn" }}
Requester: {{ .GetValue ".Context.createdBy" }}
referTo: https://{{ .System.domain }}/sys_request/workflow_list/workflow_detail/{{ .GetValue ".Context.id" }}
severity: Information
destinations:
- type: user
value: '{{ .GetValue ".Context.create_vm_wf_02.assignedTo" }}'