Job Triggers

Once a job is completed (successfully or failed), one or more triggers can be configured to be triggered on such event.

From the left menu in the Administration UI, the Job triggers are available via the Automation link.

See image below:

menu item
Figure 1. Job Trigger

The supported trigger types are:

Send Email Notification

Used to send e-mail to some recipients about the outcome of the job.

Invoke Webhook

Can be used to trigger some other system when a job completes.

Common Trigger Settings

There are some settings on a trigger that is common for any trigger type. These are:

Property Description Required

Name

All triggers need a name, and the name must be unique among all triggers of the same type.

Yes

Description

Optionally, a trigger can have a description describing the purpose of it

No

Trigger On

Specifies if the trigger should be applied to jobs that have Failed OR jobs that have completed Successfully.

Yes

Apply To

A trigger can be configured to be used for Jobs that uses a specific Event mapping, REST mapping and/or a Scheduled task mapping. If this is mode is selected, then from the Create/Edit screen of the Trigger, you can select which mapping the trigger is valid for.

Or it can be configured to be used for jobs that doesn’t have any associated Triggers.

It is also possible to configure a trigger to always be used, regardless if the job have other triggers. The latter could be used to ensure that for example an E-mail is always sent to some administrators upon Job failure.

Yes

Condition

Optional expression that can be used to evaluate if the trigger should be executed or not depending on some runtime parameters of the job.

Example of such runtime parameter could be the result code or result message of the Job, or some specific Job tag. Please see chapter below how to construct such condition

No

Condition Evaluation

A trigger can be conditionally executed. The condition field of the trigger can hold an expression that, if evaluated to TRUE, means that the trigger will be used. If the condition field of the trigger is empty, it implies TRUE.

The expression uses certain properties to access runtime information about the Job itself. The list of these properties are shown in this table.

Below are some examples how a condition expression could be constructed.

Test the Job Result Code:

JobResultCode == 123
JobResultCode != 123
JobResultCode > 0
JobResultCode > 0 and JobResultCode < 100

And include condition on the result message:

JobResultCode == 1 and JobResultMessage.contains('Bad input')

JobResultCode == 1 and JobResultMessage.containsIgnoreCase('bAd iNpuT')

Test against Job tags.

JobTags.contains('D365')

Another tag example

ServiceName == 'D365' and JobTags.containsIgnoreCase('DYNAMICS')

Email Trigger

The email trigger will email one or more users as defined in the TO/CC/BCC fields.

If the subject and/or the message body of the trigger is left empty, a default subject and/or message will be generated by the application. This default message contains the relevant information about the problem.

You can create a custom subject and/or message body. To do so, you will use the macros are shown in this table.

Below is an example how to construct an email message.

<body>
    <div>Hello,</div>
    <div>
        The TIF Job with description ${JobDescription?:'N/A'} failed @ ${JobEndTime?:''}.
    </div>
    <div>
        The result code was ${JobResultCode} and the result message was ${JobResultMessage?:'N/A'}.
    </div>
    <div>
        Link to job <a href="${ApplicationBaseURL}/jobs/${JobId}">HERE</a>
    </div>
</body>

Note the use of the so called 'elvis operator' to handle cases when the value is null.

Webhook Trigger

Webhook triggers will send some data to an HTTP/S endpoint. A webhook consists of the following properties.

Property Description Required

Type

The type of message to produce.

You can choose between:

Custom

Produce custom JSON

MS Teams Incoming Webhook

To send notification to a MS Teams Channel using the Incoming Webhook application from Microsoft™.

Yes

URL

The URL to call

Yes

Method

The HTTP method to be used

Yes

Content-type

The content type of the message

Yes if type is set to Custom

Message

The message itself

Yes if the type is set to Custom

Headers

Additional HTTP headers to send

No

When selecting the Webhook type custom, you must create the message yourself. To do so, you will use the macros are shown in this table.

Below is an example how to construct a webhook message using template macros.

{
    "@context": "http://schema.org/extensions",
    "@type": "MessageCard",
    "potentialAction": [
        {
            "@type": "OpenUri",
            "name": "Go to Job",
            "targets": [
                {
                    "os": "default",
                    "uri": "${ApplicationBaseURL}/jobs/${JobId}"
                }
            ]
        }
    ],
    "sections": [
        {
            "activitySubtitle": "In service ${ServiceName}",
        }
    ],
    "summary": "Job ABCD Failed",
    "themeColor": "0076D7"
}

Job Trigger Properties

The table below shows the properties that are available when evaluating the conditions on a trigger, or when for example defining the template for an E-mail message body and subject.

All properties may not be defined, some might be null depending on the job itself.
Name of Property Description Type

ApplicationBaseURL

Base URL to application

String

ApplicationName

Application name

String

JobId

The Job ID

UUID

JobConfiguration

Name of the configuration

String

JobDescription

The description

String

JobStartTime

Job start time

OffsetDateTime

JobEndTime

Job end time

OffsetDateTime

JobStatus

Status of job

String

JobHasSucceeded

True if job have succeeded

Boolean

JobHasFailed

True if job have failed

Boolean

JobTags

List of job tags

List of Strings

JobResultCode

The result code

Integer

JobResultMessage

The result message

String

JobResultDetails

The result details

String

JobSourceObjectId

ID of source object

String

JobSourceObjectType

Type of source object

String

JobSourceObjectName

Name of source object

String

JobSourceObjectRevision

Revision for source object

String

JobSourceObjectState

State of source object

String

JobSourceObjectInfo

Some extra info for the source object

String

JobEventAuthorization

The authorization context value from the event

String

JobEventClass

The event class

String

JobEventPredicate

The predicate from the event

String

JobEventType

Event type

String

JobEventUser

The 3DEXPERIENCE™ user initiating the event

String

MappingName

The name of the mapping

String

MappingType

Type of mapping, e.g. event, rest or task (scheduled task)

String

ServiceName

The name of the service

String