4.3.3.1 Example of notification of schedule and work item origin

The following are use cases of notification conditions triggered based on schedule and work items.
Clicking each use case number will take you to the description of the use case.

(Table) Examples of notification conditions based on schedule and work items

Use cases Trigger Notification condition
1 Work item Notifies of work item creation and updates.
However, if only the display order of work items is changed, no notification is made.
2 Schedule Notification of change of schedule agent.
3 Notification of reminders 5 and 60 minutes before the start of the schedule.
4 Notification of changes to specific schedules tied to recurring work.


NotesNotes

When using the schedule as a starting point, note the following.

  • The "title" value of the schedule tied to a work item will always be empty. To obtain the name of the schedule, refer to ".Context.workitem.name" instead of ".Context.title".
  • For schedules tied to work items, the information of the agent is set to "assignedUsers". Additionally, for schedules not tied to work items, the information of the agent is set to "assignedTo".
    For this reason, when specifying the agent or name in the body of the notification or the recipient of the notification, create separate YAML definitions for the Notification for the schedule tied to the work item and for the schedule not tied to the work item.
  • If you have been using the notification function before the work item management function is supported, add the following to the notification conditions of the registered YAML definition before using the work item management function to prevent unintended notifications due to work item creation or updates.

    - resource: '{{ .GetValue ".Context.workitem" }}'
      eq: ""


An example of Notification YAML definitions for each use case is shown below. For details on the YAML definitions, see “Notification, Notifier”.

[Use case 1: Notify of work item creation and updates]

When work items are created and updated, information such as the work item name and the agent is notified. In the following definition example, no notification is made when a work item with an empty start date is created and updated. Therefore, if the following operation is performed, a work item will be created, but no notification will be made.

  • Copying calendar
  • Copying work item
  • Creating calendar using a template

apiVersion: 1.0
kind: notification
type: resource
name: sample_notification_work-item
label: Notification sample 1
description: Notification regarding create or update work-item 
event:
  resource: workitem
  type: update
conditions:
  # Verify that a start date is set for the work item.
  # You can verify that the value is set by comparing it with an empty string ("") using the ne operator.
  # Since only ".Context" is used as a condition,
  # notifications are triggered regardless of whether a work item is being created or updated.
  - 
    - resource: '{{ .GetValue ".Context.startDate" }}'
      ne: ""
notifications:
  - message:
      title: '[{{ .GetValue ".Context.name" }}] has been updated.'
      body: |
        The work-item {{ .GetValue ".Context.name" }} has been updated.

        Information:
          planned start time: "{{ .GetValue ".Context.plannedStart" }}"
          assignedUsers: "{{ .GetValue ".Context.assignedUsers.name" }}"
          assignedGroup: "{{ .GetValue ".Context.assignedGroup.name" }}"
    destinations:
      - type: groupMember
        value: '{{ .GetValue ".Context.assignedGroup.id" }}'


[Use case 2: Notify of change of schedule agent]

Notifies of schedule agent changes.
Separate definitions are created for schedules that are tied to work items and schedules that are not tied to work items.

①For schedules tied to work items

apiVersion: 1.0
kind: notification
type: resource
name: sample_notification_assigned_to_me_1
label: Notification sample 2-1
description: Notification regarding new assignments for a schedule related to work-item
event:
  resource: schedule
  type: update # Notification by schedule update
conditions:
  # Context refers to the schedule after the update, and PrevContext refers to the schedule before the update.
  # Additionally, the assignees of schedules linked to work items are set in "assignedUsers".
  # The first condition checks that the "assignedUsers" values before and after the update do not match.
  # The second condition verifies that the schedule is associated with a work item.
  # By verifying that workitem is not empty,
  # you can confirm that the schedule is associated with a work item.
  - 
    - resource: '{{ .GetValue ".Context.assignedUsers" }}' # When schedule agent is changed
      ne: '{{ .GetValue ".PrevContext.assignedUsers" }}'
    - resource: '{{ .GetValue ".Context.workitem" }}'
      ne: ""
notifications:
  - message:
      title: "New assignment"
      body: |
        Schedule {{ .GetValue ".Context.workitem.name" }} is assigned to you.
      referTo:
      severity: Information
    destinations:
      - type: user
        value: '{{ .GetValue ".Context.assignedUsers" }}'


②In the case of a schedule not tied attached to work items

apiVersion: 1.0
kind: notification
type: resource
name: sample_notification_assigned_to_me_2
label: Notification sample 2-2
description: Notification regarding new assignments for a schedule not related to work-item
event:
  resource: schedule
  type: update # Notification by schedule update
conditions:
  # Context refers to the schedule after the update, and PrevContext refers to the schedule before the update.
  # For example, for schedules such as workflow schedules
  # that are not linked to work items, the assignee is set in the "assignedTo" field.
  # The first condition checks that the "assignedTo" values before and after the update do not match.
  # The second condition verifies that the schedule is not associated with a work item.
  # By verifying that "workitem" is empty,
  # you can confirm that the schedule is not associated with a work item.
  - 
    - resource: '{{ .GetValue ".Context.assignedTo" }}' # When schedule agent is changed
      ne: '{{ .GetValue ".PrevContext.assignedTo" }}'
    - resource: '{{ .GetValue ".Context.workitem" }}'
      eq: ""
notifications:
  - message:
      title: "New assignment"
      body: |
        Schedule {{ .GetValue ".Context.title" }} is assigned to you.
      referTo:
      severity: Information
    destinations:
      - type: user
        value: '{{ .GetValue ".Context.assignedTo" }}'


[Use case 3: Notify of reminders 5 and 60 minutes before the start of the schedule]

Notifies of reminders 5 and 60 minutes before the start of the schedule.
Separate definitions are created for schedules that are tied to work items and schedules that are not tied to work items. Schedules tied to work items are created 7 days prior to the start date of the work, so reminders can be sent for schedules within 7 days.

①For schedules tied to work items

apiVersion: 1.0
kind: notification
type: resource
name: sample_notification_remind_schedule_before_1
label: Notification sample 3-1
description: Notification for reminder of a schedule related to work-item before start time
event:
  resource: schedule
  type: time # Notification by periodic monitoring of schedule
conditions:
  # By using remaining operators, you can compare the remaining time
  # with a field that represents a date and time.
  # By specifying "remaining: 5", you can check whether it is 5 minutes before the scheduled time.
  # You can specify OR conditions.
  # In the example below, conditions are specified for 60 minutes and 5 minutes before the schedule start time.
  # This allows you to configure settings so that notification conditions are met 60 minutes and 5 minutes before the start time.
  -  # First OR condition. The array of conditions under this becomes an AND condition.
    - resource: '{{ .GetValue ".Context.plannedStart" }}' # Notification 5 minutes before schedule start
      remaining: 5
    - resource: '{{ .GetValue ".Context.workitem" }}'
      ne: ""
  -  # Second OR condition. The array of conditions under this becomes an AND condition.
    - resource: '{{ .GetValue ".Context.plannedStart" }}' # Notification 60 minutes before schedule start
      remaining: 60
    - resource: '{{ .GetValue ".Context.workitem" }}'
      ne: ""
notifications:
  - message:
      title: "Assigned schedule reminder 5 and 60 minutes"
      body: |
        Reminding of your schedule {{ .GetValue ".Context.workitem.name" }}.
        Planned start time: {{ .GetValue ".Context.plannedStart" }}
      referTo:
      severity: Information
    destinations:
      - type: user
        value: '{{ .GetValue ".Context.assignedUsers.id" }}'


②In the case of a schedule not tied attached to work items

apiVersion: 1.0
kind: notification
type: resource
name: sample_notification_remind_schedule_before_2
label: Notification sample 3-2
description: Notification for reminder of a schedule not related to work-item before start time
event:
  resource: schedule
  type: time # Notification by periodic monitoring of schedule
conditions:
  # The difference from "①For schedules tied to work items" is
  # that it checks whether the "workitem" is empty.
  # Also, note that for destinations specified in the "destinations" label,
  # the field indicating the assignee is "assignedTo".
  - 
    - resource: '{{ .GetValue ".Context.plannedStart" }}' # Notification 5 minutes before schedule start
      remaining: 5
    - resource: '{{ .GetValue ".Context.workitem" }}'
      eq: ""
  - 
    - resource: '{{ .GetValue ".Context.plannedStart" }}' # Notification 60 minutes before schedule start
      remaining: 60
    - resource: '{{ .GetValue ".Context.workitem" }}'
      eq: ""
notifications:
  - message:
      title: "Assigned schedule reminder 5 and 60 minutes"
      body: |
        Reminding of your schedule {{ .GetValue ".Context.title" }}.
        Planned start time: {{ .GetValue ".Context.plannedStart" }}
      referTo:
      severity: Information
    destinations:
      - type: user
        value: '{{ .GetValue ".Context.assignedTo" }}'


[Use case 4: Notify of changes to specific schedules tied to recurring work]

Notifies of changes to specific schedules tied to recurring work.
Schedules tied to work items are created 7 days prior to the start date of the work. For this reason, specific schedules with a work start date of 7 days or less will be subject to notification.
The following definition example sets up a notification condition so that notification is made only when an “individual work item” for a recurring work is changed.
For changes involving an entire recurring work item or changes involving a single work item, use the definition example described in Use Case 1, “Notify of work item creation and updates” to notify of the changes.

apiVersion: 1.0
kind: notification
type: resource
name: sample_notification individual_work
label: Notification sample 4
description: Notification for update individual schedule created by work-item definition
event:
  resource: schedule
  type: update
conditions:
  # To send notifications regarding the schedule, specify schedule for resource.
  # Additionally, to send notifications regarding work items, the system determines whether all of the following conditions are met:
  #  - Whether the schedule pertains to a work item
  #  - Whether it is a specific work item within a recurring task
  #    Determine whether it is a work item that has been individually modified
  #    by checking whether "workitem.changedFromWorkItemDefinition" is "true".
  #  - Whether it is a recurring work item
  #    Determine whether it is a recurring task
  #    by checking whether "workitem.scheduleType" does not match "oneTime".
  - 
    - resource: '{{ .GetValue ".Context.workitem" }}'
      ne: ""
    - resource: '{{ .GetValue ".Context.changedFromWorkItemDefinition" }}'
      eq: "true"
    - resource: '{{ .GetValue ".Context.workitem.scheduleType" }}'
      ne: oneTime
notifications:
  - message:
      title: '[{{ .GetValue ".Context.workitem.name" }}] has been updated.'
      body: |
        The individual work of work-item {{ .GetValue ".Context.workitem.name" }} has been updated.

        Individual work Information:
          planned start time: "{{ .GetValue ".Context.plannedStart" }}"
          assignedUsers: "{{ .GetValue ".Context.assignedUsers.name" }}"
          assignedGroup: "{{ .GetValue ".Context.assignedGroup.name" }}"
    destinations:
      - type: groupMember
        value: '{{ .GetValue ".Context.assignedGroup.id" }}'