Skip to main content

Notify by Email When a Specific Item in the Content is Updated

Overview

The {assign_globals} Smarty plugin allows you to assign globally shareable variables between triggers called within the same request.
This allows you to compare the values before and after the update of the content.
In this tutorial, we will implement a feature to notify by email when a specific item in the content is updated, as an example of using {assign_globals}.

What you'll learn

In this tutorial, you will learn how to implement a feature to notify by email when a specific item in the content is updated, following these steps:

Set up an item in the content structure

Set up an extension item that will be the target of comparison in the content structure.

Set the following extension item in any content structure:

Parent fieldField nameField settings
NoneItem Name: StatusSingle choice
InputRequired
1: 1
2: 2
3: 3

Image from Gyazo

Once the content structure is ready, add a test content.

Set up custom function

Once the content is ready, write the custom function.

Click [Operations] -> [Custom function].

Image from Gyazo

Click [Add] to create custom function for "Before updating content" and "After updating content".

Image from Gyazo

Before updating content

Write the processing that will run before updating content, assigning the value of the content before the update to a global variable.

ItemValue
Titlecapture_before_update_content
Identifiercapture_before_update_content
TriggerBefore updating content / Specify the ID of the target content structure
ProcessingThe following content
capture_before_update_content
loading...

Image from Gyazo

Once you have entered the information, click [Add] to add the custom function.

After updating content

Write the processing that will run after updating content, comparing the value before and after the update assigned to the global variable, and sending a notification email if there is a change.

ItemValue
Titlecompare_before_and_after_content
Identifiercompare_before_and_after_content
TriggerAfter updating content / Specify the ID of the target content structure
ProcessingThe following content
compare_before_and_after_content
loading...
caution

Please change the part to='test@example.com' to your own notification destination.

Image from Gyazo

Once you have entered the input, click on [Add] to add custom function.

Verify the operation

When you update the status item of the content added for testing, the values before and after the update will be notified as shown below.

Image from Gyazo


Support

If you have any other questions, please contact us or check out Our Slack Community.