Mark single run job executed

Event action – Abstract

Purpose: Sets a flag for the running transaction to prevent the same 'job' from running multiple times.

IMPORTANT◄ If a chain of events is processed (see also Dispatch action event), then a flag set by a Mark single run job executed event action applies to all event handlings along the chain. Unlike variables (see Variable), which pass values within an event chain only 'forward' – from the calling to the called event handler – flags can therefore be used to provide feedback for calling event handlers. These can use the Single run job executed? rule to check whether certain flags were set during the processing of a possibly multi-level event chain when the processing is continued in the calling level.

Configuration

images/download/attachments/177911511/image-2024-9-16_12-18-58-version-1-modificationdate-1726481937459-api-v2.png

The optional Job name parameter is determined by Resolvers whose return value is interpreted as a string unless it is 'No value' (null).

The optional Job owner parameter is determined by Resolvers whose return value is interpreted as a data object.

The Single run job executed? rule uses the same parameters and compares the Job name as a string and the Job owner as a data object to determine whether or not a certain flag has been set in the previous course of the transaction.

NOTE

  • Since both parameters are optional, the event action can also be executed without parameter values (or with null/null values). The Single run job executed? rule is passed with 'matching parameters' (null/null) even if the following conditions are met.

  • The decisive factor for the Job name match is an exact match of the return value of the value resolver converted into a string. For example, an integer (e.g. a Long value from an id field of an entity) can be compared with a string of digits provided as text. If 'comma numbers', dates/time, etc. are to be compared with, for example texts provided as 'literal', the formatting must be chosen exactly to match the output format of the respective value within a Show alert (Popup) event action.

  • How data objects in the Job owner parameter are compared depends on the object type in question:

    • If an entity or an attribute of an entity with a system-managed ID (id) is specified as a Job owner, then the matching refers exclusively to the ID (id) of the object, so that it is 'recognized' by a Single run job executed? rule even if changes have been made to the entity's data since the flag was set.

    • If a freely defined data object (e.g. a 'Client object') is assigned as a Job owner, then the matching process evaluates all the data contained in the object (its hash value), which must match between an assignment when the flag is set and the object supplied in the Single run job executed? rule. Whether it is actually the same object instance (see also Create instance) is irrelevant, as long as all characteristics match.

Examples

Typical examples of use

Requirements:

  1. When saving a purchase order (business object), an event handler checks whether the reference attribute 'Order number' has been filled in for the first time. If so, the tracking state 'Commissioned' is to be set for the order.

  2. Another event handler is triggered by setting the tracking status 'Commissioned'. It automatically assigns the reference attribute 'Order number' with a value from a number range (see Number range), if an 'Order' does not yet have a concrete specification.

The 'commissioning' of an order should therefore be able to be triggered – interactively or via integration – in two different ways: Either by entering an order number in the order or by setting the tracking state 'Commissioned'.

When assigning the 'Commissioned' tracking state to a business object without the 'Order number' or further arrangements, the tracking status would be added twice, because when the 'Order number' is automatically filled by the second event handler, the first event handler is triggered, which then detects that the 'Order number' has been filled and therefore assigns the 'Commissioned' tracking state again. Even if no infinite loop is created here, because the second event handler is only active as long as the 'Order number' is still missing, the double assignment of the tracking state should be prevented.

images/download/attachments/177911511/image2021-2-15_16-42-55-version-1-modificationdate-1726478459516-api-v2.png

Configuration:

As shown schematically above, the Mark single run job executed event action is used in conjunction with the Single run job executed? rule in the two event handlings involved.

In this specific case, the Job name 'TS_ORDER' is assigned as static text and the unique ID of the purchase order is assigned as the Job owner, as executed in the following configuration for the Mark single run job executed event action:

images/download/attachments/177911511/image-2024-9-16_12-13-16-version-1-modificationdate-1726481596300-api-v2.png

NOTE◄ The Single run job executed? rule must use the same parameter values.

Alternative usage (return value from an event chain)

The decisive factor is that the check is to be triggered for all existing company and address attributes at certain working state changes in order to be able to consider the check results for certain company types (see Company type) in specific rules and case distinctions in the further course of the calling event handling. For this purpose, flags should be set with the help of the event action Mark single run job executed, whose Job name specifies the severity of a violation, while as a parameter Job owner specifies the Company type of the company and address attribute.

Configuration:

  • The event handler shown on the right reacts to a Custom action event ('Check address') as Triggering events, which is triggered at the time of the check by the calling event handler shown below in a loop over all (relevant) company and address attributes of a business object.


  • The Validating rule here is limited to a Check type that ensures that the 'Input value' for the event is of the 'Company and address attribute' type, as expected.


  • As an Action on passed rule, an If then else event action is executed, which distinguishes two conditional branches as a case distinction, whose conditions qualify the 'warning' or 'error' status for the address.

  • The left branch defines a 'warning' by assigning the text ADDR_WARNING as the Job name to the Mark single run job executed event action, while the Company type (companyType) from the attribute passed as input value is entered as the Job owner.

  • The right branch defines an 'error' by assigning the text ADDR_ERROR as the Job name to the Mark single run job executed event action, while the Company type (companyType) from the attribute that was passed as input value is entered as the Job owner.

►NOTE◄ The calling of Mark single run job executed for the declaration of an 'error' or a 'warning' could be done within a more complex event handler in different places, and in such a way that for the same Company type both a 'warning' and an 'error' are reported. The configuration on the right eliminates this against the background of a special test logic, which should not play a role here.

images/download/attachments/177911511/image2021-2-15_16-48-52-version-1-modificationdate-1726478459507-api-v2.png

A calling event handling for this check might look something like this:

In the example, the calling event handler per Check type refers to the business object type 'Purchase order' (not shown in the image).

The following event actions are executed as Actions on passed rule:

  • First, a For each loop is executed over all company and address attributes, which triggers the 'Check address' event for each existing company and address attribute of the order (Dispatch action event). Depending on the course of the check, specific flags (warning/error) will be set for the Company type defined in the attribute.

  • Following the checking of all addresses, a single If then else event action is carried out here as an example, which checks for two flags for 'errors' for different 'company types': If an 'error' flag has been set for the address for the 'Consignor' Company type or the 'Consignee' company type in the purchase order, then the current transaction is to be terminated by an Abort (incl. rollback and notification).

  • The check here within a Single run job executed? rule refers on the one hand to the Job name ADDR_ERROR (text) and on the other to the respective Company type, which was selected here in each case via Resolvers for Static values of the type 'Any dynamic enum'.

images/download/attachments/177911511/image2021-2-15_17-2-13-version-1-modificationdate-1726478459492-api-v2.png