Item Triggers

Item Triggers enables you to define scenarios, where certain changes or operations on an item will trigger a given reaction from system.

A lot of use cases exist; these are only a few examples:

  • If a certain product feature is changed, set status to “review”

  • If feature A is set to a specific value, set feature B to some “derived” value

  • Notify product manager about changes to his/her products

  • When some feature was changed, regenerate an export file (or a report, or…)

Up until today, the only way of achieving this has been to use external modules, or to schedule an Action which constantly monitors all data for these changes.

With Item Triggers, Perfion can now directly invoke such automated rule-based responses to user-initiated interactions.

Prerequisite

Perfion Item Triggers requires Perfion version 2021-R2 or later.

Activation

Perfion Item Triggers must be activated by an administrator. Activation is done in Administration -> Settings:

Managing Item Triggers

This chapter describes how to set up and manage Item Triggers in Perfion.

Overview screen

To get started with Item Triggers, go to Administration -> Item Triggers:

This will open the Item Triggers main window where you will see a list of current Item Triggers:

In the top menu there are the following options:

New

Create a new Item Trigger

Edit

Edit the selected Item Trigger

Double-click will also open the Item Trigger editor

Delete

Delete the selected Item Trigger. The deletion will be saved when the overview windows is closed by the OK button.

Refresh

Refreshes data from the database

Move Up/Down

Change the priority of the selected Item Trigger. If two Item Triggers change the same feature or execute the same Action the highest priority will overrule the lower priority. The changed order will be saved when the overview windows is closed by the OK button.

Log

Open the log of executed Actions triggered by Item Triggers.

Create a new Item Trigger

Name and description

Click New to open an empty Item Trigger editor. Give your trigger a name and a meaningful description:

Notice that you can Enable or Disable the trigger according to your preferences.

Select Base Feature

Now select the Base Feature the trigger must react to. You can choose between all selectable features.

In this case, we have selected Product:

Notice that the selected Base Feature is shown in the Item Trigger area at the bottom of the screen.

Select trigger(s)

When a Base Feature has been selected, a list of triggers become available. You can choose between two different types:

  • Feature Triggers:                               Reacts to changes in one or more features

  • Item Trigger:                                        Reacts when an item is created or deleted

Select the trigger you need. In this case, we have selected the feature trigger When value is updated in specific feature:

Notice that the selected Trigger is shown in the Item Trigger area at the bottom of the screen.

Customize trigger

The selected Trigger must be customized to fit your requirements.

In the Item Trigger area, click the blue and underlined texts to specify the exact criteria for the selected trigger. In this example, our trigger must react to updates in the EAN feature done by Jesper:

Add condition (optional)

In some situations, you only want a trigger to be activated if one or more secondary conditions are true. You can specify these conditions step 3.

In this example, we have created a condition that specifies, that the trigger must only be activated, if Status is Approved. The result is that the trigger will ignore EAN updates for all other Status values.

Notice that the condition is customized in the Item Trigger area at the bottom of the screen.

Add activity

The last step is to add the activity the trigger must perform when activated. You specify this in step 4.

In this example, we have defined that the trigger must update the Status value to Review.

Remark: It Actions is not installed, the “Execute Action” is not visible.

Edit or delete item triggers

Item triggers can be edited or deleted from the main menu. Notice that the highlighted item trigger is affected; not the ones checked in the Enabled column:

You edit an existing item trigger the same way you create it:

  • Triggers, Conditions and Activities can be added, edited and deleted individually

  • To change the Base Feature, you must first delete all Triggers, Conditions and Activities

Item Triggers at work

Once defined and activated, Item Triggers work as “invisible helpers” in Perfion. Users do not have to do anything different from what they are used to.

Grid updates

When a value is updated in grid, the item trigger activates automatically and updates the related feature values:

Note that the trigger will activate on all updated items. Assume you had created a trigger to react to Color updates. If you update Color on multiple items in one go (by copy-pasting same value to multiple cells or doing a CTRL+Enter update), the Status value would be updated for all items.

Item editor updates

When a value is updated in item editor, the item trigger activates when Save & Close or Save is clicked. By clicking Save the result of the trigger activity is immediately visible:

Compare tool

When an EAN value is updated in the Compare tool, the item trigger activates when one of the Save options are used:

Import and API updates

When one or more EAN values are updated via an import or an API query, the item trigger activates on all affected items:

Triggers and Actions

Key concept

When a trigger is configured to execute an Action, the trigger will forward a dataset with details of the affected item to the Action when the trigger is activated. The Action must in turn be constructed to respond to this incoming dataset and perform its magic on the related item.

NOTE: If multiple items are updated via an import and this invokes the same trigger on multiple items, the trigger will forward data for all affected items to the action in one dataset. This means that the invoked action must be constructed to handle more than one row in the incoming dataset.

Prerequisite

To execute triggered Actions, the Application Server must run. See Application Server for more information.

Datasets forwarded by triggers to actions

When a trigger executes an action, it forwards three datasets:

  • Previous:            This dataset contains information about the item before it was updated

  • New:                   The dataset contains information about the item after it was updated

  • Coalesced:           The dataset combines information about the item before and after it was updated

The datasets Previous and New have different columns depending on whether the trigger is a Feature Trigger or an Item Trigger, see Select trigger(s).

The table column are these for Previous and New:

Feature Trigger

Note

 

Item Trigger

Note

ItemId

Item identification

 

Id

Item identification

SpecType

Feature identification

 

ParentId

Parent identification if any

Language

Language, blank for non-localizable features

 

BaseType

Base Feature identification

Number

Feature value, Item is Id for a selectable feature.

 

Brand

0 for normal item

1 for virtual item

2 for catalog item

Date

 

Order

Relative order of item among siblings

String

 

CreatedBy

Created by

Text

 

CreatedDate

Created date

BinaryId

 

PermitID

User permission reference

Item

 

ModifiedDate

Modified date

ModifiedDate

Modified date

 

DisplayStyle

Not used

ModifiedBy

Modified by

 

 

 

The table column are these for Coalesced:

Feature Trigger

Note

ItemId

Item identification

SpecType

Feature identification

Language

Language, blank for non-localizable features

PreviousNumber

Feature value, Item is Id for a selectable feature.

NewNumber

PreviousDate

NewDate

PreviousString

NewString

PreviousText

NewText

PreviousBinaryId

NewBinaryId

PreviousItem

NewItem

ChangeType

From Perfion 2023R1 the ChangeType is added and contain “Insert”, “Update” or “Delete”

Constructing a “Trigger Action”

Action using Import

Assume you want to create a trigger, that copies the previous EAN value to a “backup” feature (PreviousEAN) when the primary EAN feature is updated. This requires a “trigger action”.

The trigger needed to execute this action would look like this:

The action referenced in this trigger (Copy previous EAN) could look like this:

The action starts with the incoming Previous dataset from the trigger. From that data, it constructs a new ItemData dataset with ItemID as _ID and the String value as PreviousEAN. The new dataset is then imported to Product.

Note that this action will work on a single update as well as simultaneous updates to multiple EAN values (via an import).

Action using loop

As an alternative to updating data via an IMPORT command, you can use the command EXECUTE.ACTION.LOOP to update one item at the time in a loop:

Please refer to Actions documentation for further details.

Actions log

From the Item Triggers main window, the log of triggered Actions opens.

The filters show log entries from today as default.

The top screen shows the list of Actions trigged. The status can be:

Status

Id in database

Note

New

10

New and not handled by the Application Server

Queued

20

Queued by the Application Server

Started

30

Execution of the Action is started

Success

40

Execution is completed successfully

Failed

50

Execution has failed

AbnormalTermination

60

The Application Server was abnormally terminated, and the execution of the Action was not completed

The bottom screen shows the execution logs for the selected Action from the top screen. The Log Level is set under Setting -> Application Server