Notifications HOWTO

Last modified 12 Mar 2024 13:41 +01:00
Since 4.5
This functionality is available since version 4.5. The functionality was further improved in versions 4.6, 4.7, 4.8.

Basic Information

MidPoint can be configured to send notifications upon certain events. The default configuration does not contain any notification configuration so there are no notifications sent by midPoint at all. This document show how to work with notifications for common use cases and how to improve them.

Please refer also to Notifications and Notification and Transport Configuration for reference information.

1. Setting Infrastructure Parameters

Before creating notifications, System Configuration’s Infrastructure parameters must be configured.

  • defaultHostname: defines the midPoint server hostname that will be used when generating notifications with links to midPoint GUI. Example: localhost (for local testing) or midpoint.

  • publicHttpUrlPattern: if midPoint is located behind a reverse proxy, provide URL of midPoint visible from outside. Examples:

You can use only publicHttpUrlPattern with value https://midpoint.example.com/iam and don’t need to set defaultHostname when using a reverse proxy, but please note that defaultHostname is used also for other purposes such as intra-cluster communication.
Example fragment of System configuration object:
<infrastructure>
    <defaultHostname>midpoint</defaultHostname>
    <publicHttpUrlPattern>https://$host/midpoint</publicHttpUrlPattern>
</infrastructure>

2. Message Transport Configuration

Message transport defines the notification mechanism of the notifications.

The following example configures midPoint transport named mail to send e-mail notifications via unsecured communication using host localhost and port 25:

Example fragment of System configuration (local SMTP server):
<messageTransportConfiguration>
    <mail>
        <name>mail</name>
        <server>
            <host>localhost</host>
            <port>25</port>
            <transportSecurity>none</transportSecurity>
        </server>
        <defaultFrom>idm@example.com</defaultFrom>
    </mail>
</messageTransportConfiguration>
If you are using secured communication with your SMTP server, you need to import its SSL certificate to midPoint’s keystore. Please see also Notification and Transport Configuration

The following example is useful for local testing as it creates midPoint transport named mail which redirects all e-mail notifications to a file stored in midPoint server filesystem:

Example fragment of System configuration (e-mail redirection to a file):
<messageTransportConfiguration>
    <mail>
        <name>mail</name>
        <redirectToFile>/opt/midpoint/var/log/example-mail-notifications.log</redirectToFile>
        <defaultFrom>idm@example.com</defaultFrom>
    </mail>
</messageTransportConfiguration>

Please refer to Notification and Transport Configuration for more options.

3. Default Notification Configuration

As stated earlier, there is no default notification configuration. Notification handlers need to be explicitly used. Having said that, the default configuration of the notification handlers might be useful to inspect - to know what you can expect.

In the following example we will configure only recipientExpression but not subjectExpression nor bodyExpression - e-mail subject and body will be generated by the notifiers (infrastructure parameters are omitted from the configuration)

(Show System configuration fragment)
Example System configuration object fragment
<notificationConfiguration>
    <handler>
        <name>Default Notification Handler</name>
        <description>
            The default set of notifications for demonstration purposes and/or for further customization.
        </description>

        <simpleUserNotifier>
            <name>notify-administrators-about-users-all</name>
            <description>Notify system administrators about all user-related operations.</description>
            <recipientExpression>
                <value>idm@example.com</value>(1)
            </recipientExpression>
            <transport>mail</transport>
        </simpleUserNotifier>
    </handler>
</notificationConfiguration>
<messageTransportConfiguration>
    <mail>
        <name>mail</name>
        <server>
            <host>localhost</host>
            <port>25</port>
            <transportSecurity>none</transportSecurity>
        </server>
        <defaultFrom>idm@example.com</defaultFrom>
    </mail>
</messageTransportConfiguration>
1 Fixed e-mail recipient idm@example.com

Create a new testing user with the following properties:

  • Name: test-notification1

  • Given name: Test

  • Family name: Notification1

  • Full name: Test Notification1

  • E-mail address: test.notification1@example.com

The e-mail notification will be created and delivered with the default content:

simpleUserNotifier create default
Figure 1. Default simpleUserNotifier - user creation

Please note how the default content was constructed:

  • From: idm@example.com (configured in messageTransportConfiguration as defaultFrom)

  • To: idm@example.com (configured in simpleUserNotifier as recipientExpression)

  • Subject: User creation notification (generated by the notifier itself)

  • Message body: generated by the notifier itself, includes the following information:

    • operation status (SUCCESS)

    • user related to the operation

    • notification creation (event) date

    • changes as recorded by midPoint

    • information about requester (user performing the operation - administrator)

    • information about channel of the operation

As you can see, the notification is quite information-rich, but looks quite technical, too. We will improve the notifications later.

Let’s add other notifiers now.

(Show System configuration fragment)
Example System configuration object fragment:
<notificationConfiguration>
    <handler>
        <name>Default Notification Handler</name>
        <description>
            The default set of notifications for demonstration purposes and/or for further customization.
            TODO: add lifecycleStatus when available.
        </description>

        <simpleUserNotifier>
            <name>notify-administrators-about-users-all</name>
            <description>Notify system administrators about all user-related operations.</description>
            <recipientExpression>
                <value>idm@example.com</value>(1)
            </recipientExpression>
            <transport>mail</transport>
        </simpleUserNotifier>

        <simpleResourceObjectNotifier>
            <name>notify-administrators-about-resource-objects-all</name>
            <description>Notify system administrator about all resource objects.</description>
            <recipientExpression>
                <value>idm@example.com</value>(2)
            </recipientExpression>
            <transport>mail</transport>
        </simpleResourceObjectNotifier>

        <userPasswordNotifier>
            <name>notify-administrators-about-midpoint-password</name>
            <description>New midPoint user password is sent to the administrator</description>
            <recipientExpression>
                <value>idm@example.com</value>(3)
            </recipientExpression>
            <transport>mail</transport>
        </userPasswordNotifier>

        <accountPasswordNotifier>
            <name>notify-user-about-new-account-password</name>
            <description>Notification with new account password is sent to the account owner (if he/she has e-mail address)</description>
            <transport>mail</transport>
            (4)
        </accountPasswordNotifier>
    </handler>
</notificationConfiguration>
<messageTransportConfiguration>
    <mail>
        <name>mail</name>
        <server>
            <host>localhost</host>
            <port>25</port>
            <transportSecurity>none</transportSecurity>
        </server>
        <defaultFrom>idm@example.com</defaultFrom>
    </mail>
</messageTransportConfiguration>
1 Fixed e-mail recipient idm@example.com
2 Fixed e-mail recipient idm@example.com
3 Fixed e-mail recipient idm@example.com
4 No recipient defined; will use the account owner if his/her e-mail address is defined in midPoint

Create a new testing user with the following properties:

  • Name: test-notification2

  • Given name: Test

  • Family name: Notification2

  • Full name: Test Notification2

  • E-mail address: test.notification2@example.com

  • Password: Secret123

The e-mail notification will be created and delivered with the default content:

simpleUserNotifier create default 2
Figure 2. Default simpleUserNotifier - user creation

Please note how the default content was constructed:

  • From: idm@example.com (configured in messageTransportConfiguration as defaultFrom)

  • To: idm@example.com (configured in simpleUserNotifier as recipientExpression)

  • Subject: User creation notification (generated by the notifier itself)

  • Message body: generated by the notifier itself, includes the following information:

    • operation status (SUCCESS)

    • user related to the operation

    • notification creation (event) date

    • changes as recorded by midPoint, password is not revealed here

    • information about requester (user performing the operation - administrator)

    • information about channel of the operation

Second e-mail notification has been created and delivered with the default content:

simpleUserPasswordNotifier create
Figure 3. Default simpleUserPasswordNotifier - user creation

Please note how the default content was constructed:

  • From: idm@example.com (configured in messageTransportConfiguration as defaultFrom)

  • To: idm@example.com (configured in simpleUserNotifier as recipientExpression)

  • Subject: User password notification (generated by the notifier itself)

  • Message body: generated by the notifier itself, includes the following information:

    • password for the new user

Let’s see how the e-mail notifications work with other-than-create operations.

Update your test-notification2 user by changing user’s description property.

The e-mail notification will be created and delivered with the default content:

simpleUserNotifier modify default 2
Figure 4. Default simpleUserNotifier - user modification

Please note how the default content was constructed:

  • From: idm@example.com (configured in messageTransportConfiguration as defaultFrom)

  • To: idm@example.com (configured in simpleUserNotifier as recipientExpression)

  • Subject: User modification notification (generated by the notifier itself)

  • Message body: generated by the notifier itself, includes the following information:

    • operation status (SUCCESS)

    • user related to the operation

    • notification creation (event) date

    • changes as recorded by midPoint (description property)

    • information about requester (user performing the operation - administrator)

    • information about channel of the operation

Let’s see how the notifications behave with a password change. Change your test-notification2 user’s password.

The e-mail notification will be created and delivered with the default content:

simpleUserNotifier modify password default 2
Figure 5. Default simpleUserNotifier - user password modification

Please note how the default content was constructed:

  • From: idm@example.com (configured in messageTransportConfiguration as defaultFrom)

  • To: idm@example.com (configured in simpleUserNotifier as recipientExpression)

  • Subject: User modification notification (generated by the notifier itself)

  • Message body: generated by the notifier itself, includes the following information:

    • operation status (SUCCESS)

    • user related to the operation

    • notification creation (event) date

    • changes as recorded by midPoint (password is not revealed)

    • information about requester (user performing the operation - administrator)

    • information about channel of the operation

The second notification shows:

simpleUserPasswordNotifier modify
Figure 6. Default userPasswordNotifier with password change

Please note how the default content was constructed:

  • From: idm@example.com (configured in messageTransportConfiguration as defaultFrom)

  • To: idm@example.com (configured in simpleUserNotifier as recipientExpression)

  • Subject: User password notification (generated by the notifier itself)

  • Message body: generated by the notifier itself, includes the following information:

    • new password for the existing user

As you can see, the default behavior is to send notification also about password changes and not only about initial passwords.

In midPoint, edit test-notification2 user and assign a role to provision the account in a target system.

The e-mail notification will be created and delivered with the default content:

simpleResourceAccountNotifier create
Figure 7. Default simpleResourceObjectNotifier - account creation

Please note how the default content was constructed:

  • From: idm@example.com (configured in messageTransportConfiguration as defaultFrom)

  • To: idm@example.com (configured in simpleResourceObjectNotifier as recipientExpression)

  • Subject: Account creation notification (generated by the notifier itself)

  • Message body: generated by the notifier itself, includes the following information:

    • operation status (SUCCESS)

    • user related to the operation (owner of the account)

    • notification creation (event) date

    • account changes as recorded by midPoint (password is not revealed)

    • information about requester (user performing the operation - administrator)

    • information about channel of the operation

The second notification shows:

simpleAccountPasswordNotifier create
Figure 8. Default simpleAccountPasswordNotifier - account creation

Please note how the default content was constructed:

  • From: idm@example.com (configured in messageTransportConfiguration as defaultFrom)

  • To: test.notification2@example.com (the account owner, used as default if recipientExpression in simpleAccountPasswordNotifier is not defined and that user has e-mail address)

  • Subject: Account password notification (generated by the notifier itself)

  • Message body: generated by the notifier itself, includes the following information:

    • password for the new account

(A third notification related to user modification - role assignment - would be sent as well. This is omitted for brevity.)

As you can see, the same notifications are used for all user-related operations.

To change this default behavior, we need to use filters.

Lessons learned:

  • the default configuration of notifiers can be very useful…​ but also very technical

  • the default configuration of notifiers is used for all kinds of operations (Add, Modify, Delete)

4. Adding Filters

Let’s configure our password notifiers to send passwords only for add operation (when user/account is created) and only if the operation was successful.

(Show System configuration fragment)
Example System configuration object fragment:
<notificationConfiguration>
    <handler>
        <name>Default Notification Handler</name>
        <description>
            The default set of notifications for demonstration purposes and/or for further customization.
        </description>

        <simpleUserNotifier>
            <name>notify-administrators-about-users-all</name>
            <description>Notify system administrators about all user-related operations.</description>
            <recipientExpression>
                <value>idm@example.com</value>(1)
            </recipientExpression>
            <transport>mail</transport>
        </simpleUserNotifier>

        <simpleResourceObjectNotifier>
            <name>notify-administrators-about-resource-objects-all</name>
            <description>Notify system administrator about all resource objects.</description>
            <recipientExpression>
                <value>idm@example.com</value>(2)
            </recipientExpression>
            <transport>mail</transport>
        </simpleResourceObjectNotifier>

        <userPasswordNotifier>
            <name>notify-administrators-about-midpoint-password</name>
            <description>New midPoint user password is sent to the administrator but only if user was successfully created.</description>
            <operation>add</operation>(4)
            <status>success</status>(5)
            <recipientExpression>
                <value>idm@example.com</value>(3)
            </recipientExpression>
            <transport>mail</transport>
        </userPasswordNotifier>

        <accountPasswordNotifier>
            <name>notify-user-about-new-account-password</name>
            <description>Notification with new account password is sent to the account owner (if he/she has e-mail address), but only if the account was successfully created.</description>
            <operation>add</operation>(4)
            <status>success</status>(5)
            <transport>mail</transport>
        </accountPasswordNotifier>
    </handler>
</notificationConfiguration>
<messageTransportConfiguration>
    <mail>
        <name>mail</name>
        <server>
            <host>localhost</host>
            <port>25</port>
            <transportSecurity>none</transportSecurity>
        </server>
        <defaultFrom>idm@example.com</defaultFrom>
    </mail>
</messageTransportConfiguration>
1 Fixed e-mail recipient idm@example.com
2 Fixed e-mail recipient idm@example.com
3 Fixed e-mail recipient idm@example.com
4 Only for operation add
5 Only if operation finished successfully

Change your test-notification2 user’s password.

This time, the user/password notifications won’t be sent. Only user/account changes will be reported, not revealing the actual password.

Lessons learned:

  • adding filters to otherwise default configuration of notifiers is easy, but very powerful

5. Separating Notifiers Using Filters

Filters can be used to create different notifications for different operations, statuses or recipients. This allows to create specific subjects - if needed.

(Show System configuration fragment)
Example System configuration object fragment:
<notificationConfiguration>
    <handler>
        <name>Default Notification Handler</name>
        <description>
            The default set of notifications for demonstration purposes and/or for further customization.
        </description>

        <simpleUserNotifier>
            <name>notify-administrators-about-users-add</name>
            <description>Notify other system administrator only about user additions</description>
            <operation>add</operation>
            <recipientExpression>
                <value>idm-add@example.com</value>
            </recipientExpression>
            <subjectExpression>
                <value>User added</value>(1)
            </subjectExpression>
            <transport>mail</transport>
        </simpleUserNotifier>

        <simpleUserNotifier>
            <name>notify-administrators-about-users-modify</name>
            <description>Notify other system administrator only about user modifications</description>
            <operation>modify</operation>
            <recipientExpression>
                <value>idm-modify@example.com</value>
            </recipientExpression>
            <subjectExpression>
                <value>User modified</value>(2)
            </subjectExpression>
            <transport>mail</transport>
        </simpleUserNotifier>

        <simpleUserNotifier>
            <name>notify-administrators-about-users-delete</name>
            <description>Notify other system administrator only about user deletions</description>
            <operation>delete</operation>
            <recipientExpression>
                <value>idm-delete@example.com</value>
            </recipientExpression>
            <subjectExpression>
                    <value>User deleted</value>(3)
            </subjectExpression>
            <transport>mail</transport>
        </simpleUserNotifier>

        <simpleResourceObjectNotifier>
            <name>notify-administrators-about-resource-objects-all</name>
            <description>Notify system administrator about all resource objects.</description>
            <recipientExpression>
                <value>idm@example.com</value>
            </recipientExpression>
            <transport>mail</transport>
        </simpleResourceObjectNotifier>

        <userPasswordNotifier>
            <name>notify-administrators-about-midpoint-password</name>
            <description>New midPoint user password is sent to the administrator but only if user was successfully created.</description>
            <operation>add</operation>
            <status>success</status>
            <recipientExpression>
                <value>idm@example.com</value>
            </recipientExpression>
            <transport>mail</transport>
        </userPasswordNotifier>

        <accountPasswordNotifier>
            <name>notify-user-about-new-account-password</name>
            <description>Notification with new account password is sent to the account owner (if he/she has e-mail address), but only if the account was successfully created.</description>
            <operation>add</operation>
            <status>success</status>
            <transport>mail</transport>
        </accountPasswordNotifier>
    </handler>
</notificationConfiguration>
<messageTransportConfiguration>
    <mail>
        <name>mail</name>
        <server>
            <host>localhost</host>
            <port>25</port>
            <transportSecurity>none</transportSecurity>
        </server>
        <defaultFrom>idm@example.com</defaultFrom>
    </mail>
</messageTransportConfiguration>
1 Subject for user additions
2 Subject for user modifications
3 Subject for user deletions

In midPoint, edit test-notification2 user and update user’s description once again.

The e-mail notification will be created and delivered with the default content:

simpleUserNotifier separate modify
Figure 9. simpleResourceObjectNotifier - subjectExpression - user modification

Please note how the default content was constructed:

  • From: idm@example.com (configured in messageTransportConfiguration as defaultFrom)

  • To: idm-modify@example.com (configured in simpleUserNotifier for modify operation as recipientExpression)

  • Subject: User modified (configured in simpleUserNotifier for modify operation as subjectExpression)

  • Message body: generated by the notifier itself, includes the following information:

    • operation status (SUCCESS)

    • user related to the operation

    • notification creation (event) date

    • changes as recorded by midPoint

    • information about requester (user performing the operation - administrator)

    • information about channel of the operation

Add, modify and delete operations now send different e-mail notifications using different subjects and recipients.

Lessons learned:

  • notifications can be sent to different recipients with different subjects using filters

6. Adding Message Templates (Plain Text)

We could re-use the previous example to also populate different message bodies. We will introduce the message templates to make it even more universal and to move the configuration from System configuration to separate objects.

Please note: we will use various variables now to create dynamic messages. Refer to expression variables for more information.

(Show System configuration fragment)
Example System configuration object fragment:
<notificationConfiguration>
    <handler>
        <name>Default Notification Handler</name>
        <description>
            The default set of notifications for demonstration purposes and/or for further customization.
        </description>

        <simpleUserNotifier>
            <name>notify-administrators-about-users-add</name>
            <description>Notify other system administrator only about user additions</description>
            <operation>add</operation>
            <recipientExpression>
                <value>idm2@example.com</value>
            </recipientExpression>
            <messageTemplateRef oid="95e1cd9e-abb7-4e9c-aa48-e9bc70282bc2"/>(1)
            <transport>mail</transport>
        </simpleUserNotifier>

        <simpleUserNotifier>
            <name>notify-administrators-about-users-modify</name>
            <description>Notify other system administrator only about user modifications</description>
            <operation>modify</operation>
            <recipientExpression>
                <value>idm2@example.com</value>
            </recipientExpression>
            <subjectExpression>
                <value>User modified</value>(2)
            </subjectExpression>
            <transport>mail</transport>
        </simpleUserNotifier>

        <simpleUserNotifier>
            <name>notify-administrators-about-users-delete</name>
            <description>Notify other system administrator only about user deletions</description>
            <operation>delete</operation>
            <recipientExpression>
                <value>idm2@example.com</value>
            </recipientExpression>
            <subjectExpression>
                <value>User deleted</value>(3)
            </subjectExpression>
            <transport>mail</transport>
        </simpleUserNotifier>
    </handler>
</notificationConfiguration>
<messageTransportConfiguration>
    <mail>
        <name>mail</name>
        <server>
            <host>localhost</host>
            <port>25</port>
            <transportSecurity>none</transportSecurity>
        </server>
        <defaultFrom>idm@example.com</defaultFrom>
    </mail>
</messageTransportConfiguration>
1 Message template should specify the subject
2 Subject for modified users defined here
3 Subject for deleted users deleted here

This time we need also the message template:

(Show Message template)
Message template message-template-user-add
<messageTemplate xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
                 oid="95e1cd9e-abb7-4e9c-aa48-e9bc70282bc2">
    <name>message-template-user-add</name>
    <description>Template for simple user notifier for added users, to be customized.</description>
    <defaultContent>
        <subjectExpression>(1)
            <script>
                <language>velocity</language>(2)
                <code>[IDM] User $requestee.name added with operation result#if ($event.success) SUCCESS#elseif ($event.failure) FAILURE#else IN PROGRESS#end</code>
            </script>
        </subjectExpression>
        <bodyExpression>(3)
            <script>
                <language>velocity</language>(2)
                <code>New User Notification

New user $!event.requesteeDisplayName ($event.requesteeName) was created (status: $event.statusAsText)

The user creation was requested by $event.requesterDisplayName ($event.requesterName)

This notification has been from an unmonitored mailbox.
IT Department of Example, Inc.
                </code>
            </script>
        </bodyExpression>
    </defaultContent>
</messageTemplate>
1 Subject expression
2 Velocity language used for expressions (we could also use Groovy).
3 Body expression

Create a new testing user with the following properties:

  • Name: test-notification4

  • Given name: Test

  • Family name: Notification4

  • Full name: Test Notification4

  • E-mail address: test.notification4@example.com

The e-mail notification will be created and delivered with the following content:

simpleUserNotifier create with template plain
Figure 10. simpleUserNotifier with message template - user add

Please note how the e-mail content was constructed:

  • From: idm@example.com (configured in messageTransportConfiguration as defaultFrom)

  • To: idm2@example.com (configured in simpleUserNotifier for modify operation as recipientExpression)

  • Subject: [IDM] User test-notification4 added with operation result SUCCESS (created in message-template-user-add used by simpleUserNotifier with operation: add)

  • Message body: generated by the message template with the following information:

    • operation status (SUCCESS)

    • user related to the operation

    • information about requester (user performing the operation - administrator)

Add, modify and delete operations now send different e-mail notifications using different message templates which produce different subjects and bodies.

Lessons learned:

  • message templates allow customization outside System configuration. Typically, they are used for subjectExpression and bodyExpression. The message templates can utilize various expression variables available for notifications.

7. Adding Message Templates (HTML)

When we start using message templates to override the default e-mail content generated by notifiers, we can move to HTML content as well.

We will update the message template for add operation.

(Show Message template)
Message template message-template-user-add
<messageTemplate xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
                 oid="95e1cd9e-abb7-4e9c-aa48-e9bc70282bc2">
    <name>message-template-user-add</name>
    <description>Template for simple user notifier for added users, to be customized.</description>
    <defaultContent>
        <contentType>text/html; charset=UTF-8</contentType>(1)
        <subjectExpression>
            <script>
                <language>velocity</language>
                <code>[IDM] User $requestee.name added with operation result#if ($event.success) SUCCESS#elseif ($event.failure) FAILURE#else IN PROGRESS#end</code>
            </script>
        </subjectExpression>
        <bodyExpression>
            <script>
                <language>velocity</language>
                <code><![CDATA[
<html>
    <head>
        <style>
/* Use your CSS styles as needed */
div.footer {
    height: 64px;
    width: 100%;
    border-top: solid thin;
    margin-left: auto;
    margin-right: auto;
    background-color: ivory;
}

body {
    font: normal 14px Roboto, sans-serif;
}

.center {
    text-align: center;
}
        </style>
    </head>
    <body>
        <h1>New User Notification</h1>

        <p>New user <b>$!event.requesteeDisplayName</b> ($event.requesteeName) was <b>created</b> (status: $event.statusAsText)</p>

        <p>The user creation was requested by $event.requesterDisplayName ($event.requesterName)</p>

        <div class="footer">
            <img src="http://localhost/midpoint/static-web/example-logo-s.png" alt="[Example logo]" width="64" height="64" style="float:left;"/>
            <p class="center">This notification has been from an unmonitored mailbox.<br/>
            <b>IT Department of Example, Inc.</b>
            </p>
        </div>
    </body>
</html>

]]></code>
            </script>
        </bodyExpression>
    </defaultContent>
</messageTemplate>
1 Content-type specified (HTML)

Create a new testing user with the following properties:

  • Name: test-notification4

  • Given name: Test

  • Family name: Notification4

  • Full name: Test Notification4

  • E-mail address: test.notification4@example.com

The e-mail notification will be created and delivered with the following content:

simpleUserNotifier create with template html
Figure 11. simpleUserNotifier with HTML message template - user add

Please note how the e-mail content was constructed:

  • From: idm@example.com (configured in messageTransportConfiguration as defaultFrom)

  • To: idm2@example.com (configured in simpleUserNotifier for modify operation as recipientExpression)

  • Subject: [IDM] User test-notification5 added with operation result SUCCESS (created in message-template-user-add used by simpleUserNotifier with operation: add)

  • Message body: generated by the message template with the following information:

    • operation status (SUCCESS)

    • user related to the operation

    • information about requester (user performing the operation - administrator)

    • icon/logo, look and feel are defined in the HTML code of the message template

Add, modify and delete operations now send different e-mail notifications using different message templates which produce different subjects and bodies.

Lessons learned:

  • message templates can be prepared with HTML formatting

  • just like with plain text message templates, the customization is placed outside System configuration. The message templates can utilize various expression variables available for notifications.

8. Adding Attachments

If needed, you can add attachments (text or binary) to your e-mails. In the following example, we will attach a file (text/plain for simplicity) for each new user to the notification.

We will update the message template for add operation.

(Show Message template)
Message template message-template-user-add
<messageTemplate xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
                 oid="95e1cd9e-abb7-4e9c-aa48-e9bc70282bc2">
    <name>message-template-user-add</name>
    <description>Template for simple user notifier for added users, to be customized.</description>
    <defaultContent>
        <contentType>text/html; charset=UTF-8</contentType>
        <subjectExpression>
            <script>
                <language>velocity</language>
                <code>[IDM] User $requestee.name added with operation result#if ($event.success) SUCCESS#elseif ($event.failure) FAILURE#else IN PROGRESS#end</code>
            </script>
        </subjectExpression>
        <bodyExpression>
            <script>
                <language>velocity</language>
                <code><![CDATA[
<html>
    <head>
        <style>
/* Use your CSS styles as needed */
div.footer {
    height: 64px;
    width: 100%;
    border-top: solid thin;
    margin-left: auto;
    margin-right: auto;
    background-color: ivory;
}

body {
    font: normal 14px Roboto, sans-serif;
}

.center {
    text-align: center;
}
        </style>
    </head>
    <body>
        <h1>New User Notification</h1>

        <p>New user <b>$!event.requesteeDisplayName</b> ($event.requesteeName) was <b>created</b> (status: $event.statusAsText)</p>

        <p>The user creation was requested by $event.requesterDisplayName ($event.requesterName)</p>

        <div class="footer">
            <img src="http://localhost/midpoint/static-web/example-logo-s.png" alt="[Example logo]" width="64" height="64" style="float:left;"/>
            <p class="center">This notification has been from an unmonitored mailbox.<br/>
            <b>IT Department of Example, Inc.</b>
            </p>
        </div>
    </body>
</html>

]]></code>
            </script>
        </bodyExpression>
        <attachment>(1)
            <contentType>text/plain</contentType>
            <contentId>attached-password-notes.txt</contentId>
            <fileName>password-notes.txt</fileName>
            <contentFromFile>/opt/midpoint/var/attachments/password-notices.txt</contentFromFile>
        </attachment>
    </defaultContent>
</messageTemplate>
1 Attachment definition for /opt/midpoint/var/attachments/password-notices.txt file

Create a new testing user with the following properties:

  • Name: test-notification6

  • Given name: Test

  • Family name: Notification6

  • Full name: Test Notification6

  • E-mail address: test.notification6@example.com

The e-mail notification will be created and delivered with the following content:

simpleUserNotifier create with template html attachment
Figure 12. simpleUserNotifier with HTML message template and attachment - user add

Please note how the e-mail content was constructed:

  • From: idm@example.com (configured in messageTransportConfiguration as defaultFrom)

  • To: idm2@example.com (configured in simpleUserNotifier for modify operation as recipientExpression)

  • Subject: [IDM] User test-notification6 added with operation result SUCCESS (created in message-template-user-add used by simpleUserNotifier with operation: add)

  • Message body: generated by the message template with the following information:

    • operation status (SUCCESS)

    • user related to the operation

    • information about requester (user performing the operation - administrator)

    • icon/logo, look and feel are defined in the HTML code of the message template

  • Attachment password-notes.txt is included (the file is located in midPoint server filesystem)

Add, modify and delete operations now send different e-mail notifications using different message templates which produce different subjects and bodies - and attachments, if needed.

Lessons learned:

  • attachments can be used in notifications to include images, documents or other information. The attached files must be available by midPoint, e.g. stored in midPoint’s midpoint.home directory (/opt/midpoint/var/ in our example) or can be constructed using the expressions.

9. Localized Message Templates

MidPoint allows localization of message templates based on recipient’s preferredLanguage or locale property. If the recipient’s preferredLanguage or locality does not match the localized content of the template, the defaults (defaultContent) will be used.

In the following example we will demonstrate this on accountPasswordNotifier which by defaults uses the account owner as the recipient. If the account owner has e-mail address defined in midPoint, it will be used and user’s preferredLanguage or locality will be considered.

(Show System configuration fragment)
Example System configuration object fragment:
<notificationConfiguration>
    <handler>
        <name>Default Notification Handler</name>
        <description>
            The default set of notifications for demonstration purposes and/or for further customization.
        </description>

        <simpleUserNotifier>
            <name>notify-administrators-about-users-add</name>
            <description>Notify other system administrator only about user additions</description>
            <operation>add</operation>
            <recipientExpression>
                <value>idm2@example.com</value>
            </recipientExpression>
            <messageTemplateRef oid="95e1cd9e-abb7-4e9c-aa48-e9bc70282bc2"/>
            <transport>mail</transport>
        </simpleUserNotifier>

        <simpleUserNotifier>
            <name>notify-administrators-about-users-modify</name>
            <description>Notify other system administrator only about user modifications</description>
            <operation>modify</operation>
            <recipientExpression>
                <value>idm2@example.com</value>
            </recipientExpression>
            <subjectExpression>
                <value>User modified</value>
            </subjectExpression>
            <transport>mail</transport>
        </simpleUserNotifier>

        <simpleUserNotifier>
            <name>notify-administrators-about-users-delete</name>
            <description>Notify other system administrator only about user deletions</description>
            <operation>delete</operation>
            <recipientExpression>
                <value>idm2@example.com</value>
            </recipientExpression>
            <subjectExpression>
                <value>User deleted</value>
            </subjectExpression>
            <transport>mail</transport>
        </simpleUserNotifier>

        <accountPasswordNotifier>
            <name>notify-user-about-new-account-password</name>
            <description>Notification with new account password is sent to the account owner (if he/she has e-mail address)</description>
            <transport>mail</transport>
            <messageTemplateRef oid="dbba04c4-75e3-4476-99cb-d4e0d78e4975" />(1)
        </accountPasswordNotifier>
    </handler>
</notificationConfiguration>
<messageTransportConfiguration>
    <mail>
        <name>mail</name>
        <server>
            <host>localhost</host>
            <port>25</port>
            <transportSecurity>none</transportSecurity>
        </server>
        <defaultFrom>idm@example.com</defaultFrom>
    </mail>
</messageTransportConfiguration>
1 Message template for accountPasswordNotifier should specify subject and body

This time we need also the message template for accountPasswordNotifier:

(Show Message template)
Message template message-template-user-add
<messageTemplate xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"  oid="dbba04c4-75e3-4476-99cb-d4e0d78e4975">
    <name>message-template-account-password</name>
    <description>Template for account password notifier, to be customized.</description>
    <defaultContent>
        <contentType>text/html; charset=UTF-8</contentType>
        <subjectExpression>
            <script>
                <language>velocity</language>
                <code>[IDM] Password for account ${event.shadowName} on ${event.resourceName}</code>
            </script>
        </subjectExpression>
        <bodyExpression>
            <script>
            <language>velocity</language>
                <code><![CDATA[
<html>
<head>
<style>
/* Use your CSS styles as needed */
div.footer {
height: 64px;
width: 100%;
border-top: solid thin;
margin-left: auto;
margin-right: auto;
background-color: ivory;
}

body {
font: normal 14px Roboto, sans-serif;
}

.center {
    text-align: center;
}
        </style>
    </head>
    <body>
        <h1>Account Password Notification</h1>
        <p>Your password for account <b>${event.shadowName}</b> on <b>${event.resourceName}</b> is: <code style="opacity: 0.1;">${event.plaintextPassword}</code></p>

        <div class="footer">
            <img src="http://localhost/midpoint/static-web/example-logo-s.png" alt="[Example logo]" width="64" height="64" style="float:left;"/>
            <p class="center">This notification has been from an unmonitored mailbox.<br/>
            <b>IT Department of Example, Inc.</b>
            </p>
        </div>
    </body>
</html>
]]></code>
            </script>
        </bodyExpression>
    </defaultContent>
    <localizedContent>(1)
        <language>sk</language>(2)
        <subjectExpression>
            <script>
                <language>velocity</language>
                <code>[IDM] Heslo pre ucet ${requestee.name}</code>
            </script>
        </subjectExpression>
        <bodyExpression>
            <script>
                <language>velocity</language>
                <code>Heslo pre účet ${event.shadowName} v ${event.resourceName} je: ${event.plaintextPassword}</code>
            </script>
        </bodyExpression>

    </localizedContent>
</messageTemplate>
1 This is the configuration for localized messages…​
2  …​ more specifically for Slovak language (sk) configured in recipient’s preferredLanguage or locale.

Create a new testing user with the following properties:

  • Name: test-notification10

  • Given name: Test

  • Family name: Notification10

  • Full name: Test Notification10

  • E-mail address: test.notification10@example.com

  • Preferred language: Slovenčina

  • Password: Secret123

  • Assign a role to create an account in a target system

The e-mail notification will be created and delivered with the following content:

simpleAccountPasswordNotifier create with template localized
Figure 13. simpleAccountNotifier - account creation with localized template

Please note how the default content was constructed:

  • From: idm@example.com (configured in messageTransportConfiguration as defaultFrom)

  • To: test.notification10@example.com (the account owner, used as default if recipientExpression in simpleAccountPasswordNotifier is not defined and that user has e-mail address)

  • Subject: [IDM] Heslo pre účet test-notification10 (created in message-template-account-password for sk localization, used by simpleAccountPasswordNotifier with operation: add)

  • Message body: created in message-template-account-password for sk localization, includes the following information:

    • password for the new account

(Other notification(s) are omitted for brevity.)

Lessons learned:

  • message templates allow localization of the notification content based on recipient’s preferredLanguage or locale properties. If recipient’s properties do not match the localized configurations, the default localization of the template will be used

This chapter will utilize the previously explained configuration concepts to achieve similar configuration also for approvals-related notifications. As not all midPoint users are required to use midPoint approvals mechanism, you can think of this chapter as an appendix.

Notifications for users involved in approvals require that their e-mail addresses are not empty.
In this examples, a single role is configured with approvals. This configuration is not included.

The System configuration object is extended with the following configuration:

(Show System configuration fragment)
Example System configuration object fragment
<notificationConfiguration>
    <handler>
    . . .
        <simpleWorkflowNotifier>(1)
            <name>notify-requester-about-workflow-start</name>
            <category>workflowProcessEvent</category>
            <description>Notification is sent to the requester (if he/she has e-mail address) when workflow starts.</description>
            <operation>add</operation>
            <messageTemplateRef oid="12ded411-8cc1-4322-b7a6-df8315591b95"/>
            <transport>mail</transport>
        </simpleWorkflowNotifier>

        <simpleWorkflowNotifier>(2)
            <name>notify-requester-about-workflow-end</name>
            <category>workflowProcessEvent</category>
            <description>Notification is sent to the requester (if he/she has e-mail address) when workflow ends.</description>
            <operation>delete</operation>
            <messageTemplateRef oid="b037aa68-cb6d-4cdd-8c5d-bb68de4fa03a"/>
            <transport>mail</transport>
        </simpleWorkflowNotifier>

        <simpleWorkflowNotifier>(3)
            <name>notify-assignee-about-workitem-creation</name>
            <category>workItemAllocationEvent</category>
            <description>Notification is sent to work item assignee (if he/she has e-mail address) when the work item is created</description>
            <operation>add</operation>
            <messageTemplateRef oid="59e32934-d240-4bc1-9276-0f6a7357e896"/>
            <transport>mail</transport>
        </simpleWorkflowNotifier>

        <simpleWorkflowNotifier>(4)
            <name>notify-assignee-about-workitem-modification</name>
            <category>workItemAllocationEvent</category>
            <description>Notification is sent to work item assignee (if he/she has e-mail address) when the work item is updated e.g. forwarded or because of deadline warning</description>
            <messageTemplateRef oid="4c7d3fca-7a99-45ba-b6a6-110710b64b1f"/>
            <operation>modify</operation>
            <transport>mail</transport>
        </simpleWorkflowNotifier>
    </handler>
</notificationConfiguration>
1 Notification is sent when approval workflow starts (event category: workflowProcessEvent, operation: add). The notification is sent to the requester by default.
2 Notification is sent when approval workflow finishes (event category: workflowProcessEvent, operation: delete). The notification is sent to the requester by default.
3 Notification is sent when workitem is created and allocated to the assignee (event category: workItemAllocationEvent, operation: add). The notification is sent to the assignee by default.
4 Notification is sent when workitem is modified, e.g. forwarded to another approver or because of the deadline warning (event category: workItemAllocationEvent, operation: modify). The notification is sent to the assignee by default.

We also need message templates:

(Show Message template for workflow start)
<messageTemplate xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
                 oid="12ded411-8cc1-4322-b7a6-df8315591b95">
    <name>message-template-workflow-event-started</name>
    <description>Template for simple workflow notifier for workflow start, to be customized.</description>
    <defaultContent>
        <contentType>text/html; charset=UTF-8</contentType>
        <subjectExpression>
            <script>
                <language>velocity</language>
                <code>[IDM] Workflow Process $event.caseName started</code>
            </script>
        </subjectExpression>
        <bodyExpression>
            <script>
                <language>velocity</language>
                <code><![CDATA[
<html>
    <head>
        <style>
/* Use your CSS styles as needed */
div.footer {
    height: 64px;
    width: 100%;
    border-top: solid thin;
    margin-left: auto;
    margin-right: auto;
    background-color: ivory;
}

body {
    font: normal 14px Roboto, sans-serif;
}

.center {
    text-align: center;
}
        </style>
    </head>
    <body>

        <h1>Workflow Notification</h1>

        <p>Workflow process $event.caseName <b>has been started</b>

        <p>The process was started by $event.requesterDisplayName ($event.requesterName)</p>

        <div class="footer">
            <img src="http://localhost/midpoint/static-web/example-logo-s.png" alt="[Example logo]" width="64" height="64" style="float:left;"/>
            <p class="center">This notification has been from an unmonitored mailbox.<br/>
            <b>IT Department of Example, Inc.</b>
            </p>
        </div>
    </body>
</html>

]]></code>
            </script>
        </bodyExpression>
    </defaultContent>
</messageTemplate>
(Show Message template for workflow end)
<messageTemplate xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
                 oid="b037aa68-cb6d-4cdd-8c5d-bb68de4fa03a">
    <name>message-template-workflow-event-finished</name>
    <description>Template for simple workflow notifier for workflow end, to be customized.</description>
    <defaultContent>
        <contentType>text/html; charset=UTF-8</contentType>
        <subjectExpression>
            <script>
                <language>velocity</language>
                <code>[IDM] Workflow Process $event.caseName has been completed#if ($event.statusAsText) with outcome $event.statusAsText #end</code>
            </script>
        </subjectExpression>
        <bodyExpression>
            <script>
                <language>velocity</language>
                <code><![CDATA[
<html>
    <head>
        <style>
/* Use your CSS styles as needed */
div.footer {
    height: 64px;
    width: 100%;
    border-top: solid thin;
    margin-left: auto;
    margin-right: auto;
    background-color: ivory;
}

body {
    font: normal 14px Roboto, sans-serif;
}

.center {
    text-align: center;
}
        </style>
    </head>
    <body>

        <h1>Workflow Notification</h1>

        <p>Workflow $event.caseName <b>has been completed</b> #if ($event.statusAsText)with outcome <b>$event.statusAsText</b>#end</p>

        <p>The process was started by $event.requesterDisplayName ($event.requesterName)</p>

        <div class="footer">
            <img src="http://localhost/midpoint/static-web/example-logo-s.png" alt="[Example logo]" width="64" height="64" style="float:left;"/>
            <p class="center">This notification has been from an unmonitored mailbox.<br/>
            <b>IT Department of Example, Inc.</b>
            </p>
        </div>
    </body>
</html>

]]></code>
            </script>
        </bodyExpression>
    </defaultContent>
</messageTemplate>
(Show Message template for workitem creation)
<messageTemplate xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
                 oid="59e32934-d240-4bc1-9276-0f6a7357e896">
    <name>message-template-workitem-added</name>
    <description>Template for simple workflow notifier for work item creation, to be customized.</description>
    <defaultContent>
        <contentType>text/html; charset=UTF-8</contentType>
        <subjectExpression>
            <script>
                <language>velocity</language>
                <code>[IDM] Work Item has been allocated to you for $event.requesteeDisplayName ($event.requesteeName) by $event.requesterDisplayName ($event.requesterName)</code>
            </script>
        </subjectExpression>
        <bodyExpression>
            <script>
                <language>velocity</language>
                <code><![CDATA[
<html>
    <head>
        <style>
/* Use your CSS styles as needed */
div.footer {
    height: 64px;
    width: 100%;
    border-top: solid thin;
    margin-left: auto;
    margin-right: auto;
    background-color: ivory;
}

body {
    font: normal 14px Roboto, sans-serif;
}

.center {
    text-align: center;
}
        </style>
    </head>
    <body>

        <h1>Workflow Notification - Your action is required</h1>

        <p><b>Work item has been allocated to you.</b></p>

        <p>The work item is for $event.requesteeDisplayName ($event.requesteeName)
        <p>The process was started by $event.requesterDisplayName ($event.requesterName)</p>

        <p>Please visit <a href="$event.workItemUrl" target="_blank">this link</a> to approve or reject the work item.</p>

        #if ( $event.getWorkItem().getDeadline() )
        <p><b>NOTE</b>: The work item must be acted upon before: <b>$event.getWorkItem().getDeadline()</b> or it will be automatically completed, rejected or escalated.</p>
        #end
        <div class="footer">
            <img src="http://localhost/midpoint/static-web/example-logo-s.png" alt="[Example logo]" width="64" height="64" style="float:left;"/>
            <p class="center">This notification has been from an unmonitored mailbox.<br/>
            <b>IT Department of Example, Inc.</b>
            </p>
        </div>
    </body>
</html>

]]></code>
            </script>
        </bodyExpression>
    </defaultContent>
</messageTemplate>
(Show Message template for workitem modification)
<messageTemplate xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
                 oid="4c7d3fca-7a99-45ba-b6a6-110710b64b1f">
    <name>message-template-workitem-modified</name>
    <description>Template for simple workflow notifier for work item modification (e.g. time out warning), to be customized.</description>
    <defaultContent>
        <contentType>text/html; charset=UTF-8</contentType>
        <subjectExpression>
            <script>
                <language>velocity</language>
                <!-- Work item will be automatically completed in 2 minutes -->
                <code>[IDM] Notice: Work Item will be automatically marked as $event.getOperationKind() on $event.getWorkItem().getDeadline()</code>
            </script>
        </subjectExpression>
        <bodyExpression>
            <script>
                <language>velocity</language>
                <code><![CDATA[
<html>
    <head>
        <style>
/* Use your CSS styles as needed */
div.footer {
    height: 64px;
    width: 100%;
    border-top: solid thin;
    margin-left: auto;
    margin-right: auto;
    background-color: ivory;
}

body {
    font: normal 14px Roboto, sans-serif;
}

.center {
    text-align: center;
}
        </style>
    </head>
    <body>

        <h1>Workflow Notification #if ( $event.getCause().getType() == "TIMED_ACTION")- Act before deadline#end</h1>

        <p><b>Work item has been allocated to you, but you have not made any decision yet.</b></p>

        <p>The work item is for $event.requesteeDisplayName ($event.requesteeName)
        <p>The process was started by $event.requesterDisplayName ($event.requesterName)</p>

        <p>Please visit <a href="$event.workItemUrl" target="_blank">this link</a> to approve or reject the work item.</p>

        #if ( $event.getWorkItem().getDeadline() )
        <p><b>NOTE</b>: The work item must be acted upon before: <b>$event.getWorkItem().getDeadline()</b> or it will be automatically completed, rejected or escalated.</p>
        #end
        <div class="footer">
            <img src="http://localhost/midpoint/static-web/example-logo-s.png" alt="[Example logo]" width="64" height="64" style="float:left;"/>
            <p class="center">This notification has been from an unmonitored mailbox.<br/>
            <b>IT Department of Example, Inc.</b>
            </p>
        </div>
    </body>
</html>

]]></code>
            </script>
        </bodyExpression>
    </defaultContent>
</messageTemplate>

If you assign an approvable role to your testing user test-notification10 with e-mail test.notification10@example.com in midPoint, the following notification will be created and delivered to the requester:

simpleWorkflowNotifier workflow start
Figure 14. simpleWorkflowNotifier - workflow start

Please note how the default content was constructed:

  • From: idm@example.com (configured in messageTransportConfiguration as defaultFrom)

  • To: administrator@example.com (the requester, used as default if that user has e-mail address)

  • Subject: [IDM] Workflow Process Assigning role "Approvable Role 1" to user "Test Notification10 (test-notification10)" started (created in message-template-workflow-event-started, used by simpleWorkflowNotifier with category: workflowProcessEvent and operation: add)

  • Message body: created in message-template-workflow-event-started, includes the following information:

    • information about the case name (also in subject) which includes information what is being assigned to whom

    • information that the process has been started

The second notification is constructed and delivered to the role assignment approver:

simpleWorkflowNotifier workitem added
Figure 15. simpleWorkflowNotifier - workitem created and allocated to approver

Please note how the default content was constructed:

  • From: idm@example.com (configured in messageTransportConfiguration as defaultFrom)

  • To: administrator@example.com (the workitem assignee (role approver), used as default if that user has e-mail address)

  • Subject: [IDM] Work Item has been allocated to you for Test Notification10 (test-notification10) by midPoint Administrator (administrator) (created in message-template-workitem-added, used by simpleWorkflowNotifier with category: workItemAllocationEvent and operation: add)

  • Message body: created in message-template-workitem-added, includes the following information:

    • information that you need to act upon the workitem and that is has been allocated to you

    • information about the requestee (test-notification10 user)

    • information about the requester (administrator user)

    • link to the workitem to approve/reject it

    • Only if a deadline has been configured: information about the workitem deadline

If the approvals are configured with a deadline for automatic workitem completion (e.g. automatic reject) and reminders, the approver will receive one or several reminder notifications:

simpleWorkflowNotifier workitem modified
Figure 16. simpleWorkflowNotifier - workitem modified because of timeout reminder

Please note how the default content was constructed:

  • From: idm@example.com (configured in messageTransportConfiguration as defaultFrom)

  • To: administrator@example.com (the workitem assignee (role approver), used as default if that user has e-mail address)

  • Subject: [IDM] Work Item will be automatically marked as COMPLETE on 2024-03-07T11:23:34.879Z (created in message-template-workitem-modified, used by simpleWorkflowNotifier with category: workItemAllocationEvent and operation: modify)

  • Message body: created in message-template-workitem-modified, includes the following information:

    • information that you need to act upon the workitem but you did not act yet

    • information about the requestee (test-notification10 user)

    • information about the requester (administrator user)

    • link to the workitem to approve/reject it

    • information about the workitem deadline

If the approver rejects the request or if the approvals are configured with a deadline for automatic workitem completion and approver fails to act in time, the workflow will be finished with reject:

simpleWorkflowNotifier workflow finished rejected
Figure 17. simpleWorkflowNotifier - workflow finished - rejected

Please note how the default content was constructed:

  • From: idm@example.com (configured in messageTransportConfiguration as defaultFrom)

  • To: administrator@example.com (the requester, used as default if that user has e-mail address)

  • Subject: [IDM] Workflow Process Assigning role "Approvable Role 1" to user "Test Notification10 (test-notification10)" has been completed with outcome Rejected, used by simpleWorkflowNotifier with category: workflowProcessEvent and operation: delete)

  • Message body: created in message-template-workflow-event-finished, includes the following information:

    • information that the workflow has been completed with outcome Rejected

    • information about the requester (administrator user)

However, if the approver approves the work item, the workflow will be finished successfully:

simpleWorkflowNotifier workflow finished approved
Figure 18. simpleWorkflowNotifier - workflow finished - approved

Please note how the default content was constructed:

  • From: idm@example.com (configured in messageTransportConfiguration as defaultFrom)

  • To: administrator@example.com (the requester, used as default if that user has e-mail address)

  • Subject: [IDM] Workflow Process Assigning role "Approvable Role 1" to user "Test Notification10 (test-notification10)" has been completed with outcome Approved, used by simpleWorkflowNotifier with category: workflowProcessEvent and operation: delete)

  • Message body: created in message-template-workflow-event-finished, includes the following information:

    • information that the workflow has been completed with outcome Approved

    • information about the requester (administrator user)

If the role assignmend caused any user/account modification and you have configured appropriate notifications, other notifications would be send after the workitem approval.

You could change the recipientExpression for simpleWorkflowNotifier and category: workflowProcessEvent to (Groovy) requestee?.emailAddress to inform the requestee about the workflow start and finish.

11. Tips And Tricks

  • if recipient’s e-mail address is not defined, e-mail is not sent

  • some notifiers have default recipients, e.g. simpleWorkflowNotifier use by default:

    • requester.emailAddress for workflowProcessEvent events

    • assignee.emailAddress for workflowAllocationEvent events

  • when working with Java methods called from Velocity, you need to prepend method with $ and enclose parameters in ${variable} notation or the method will not be called at all, e.g.:

    #set ( $obj = $midpoint.resolveReferenceIfExists( ${item.getValue().getTargetRef()} )  )
  • when using Velocity template language, be careful about newlines! Newline in Velocity becomes newline in plain text content (e.g. in e-mail subject).

    To suppress a newline while still keeping your Velocity code in multiple lines, end the line in Velocity with a comment (##):

    Suppressing newlines in Velocity
    <subjectExpression>
        <script>
            <language>velocity</language>
            <code>[IDM] Work Item has been allocated to you ##
    for $event.requesteeDisplayName ($event.requesteeName) ##
    by $event.requesterDisplayName ($event.requesterName)</code>
        </script>
    </subjectExpression>
    • this would produce the subject as: [IDM] Work Item has been allocated to you for Test Notification10 (test-notification10) by midPoint Administrator (administrator) (single line)

Was this page helpful?
YES NO
Thanks for your feedback