Create Script, Action, and Trigger in Sitecore Content Hub

Sitecore Content Hub provides a script editor feature to write custom scripts and perform our business logic. Depending on the type of script and use cases, we can trigger the script manually or automatically using triggers.

1. Script: Sitecore Content Hub offers the following Script types. To create a script in Sitecore Content you can refer to the blog post: Execute Content Hub Script using Postman

2. Action: Sitecore content Hub offers Action to perform a specific task. Action can either triggered by the user or automatically run by trigger or via the API.

To create an action, go to the Content Hub dashboard using the manage icon and click on the Action icon:

ch-script-action-trigger-1

It will open an Action page window, click on the add New Action icon:

ch-script-action-trigger-2

In the popup window, provide the Name and Label of the action, Type I am selecting Action Script, choose the script that we created earlier, and click save:

ch-script-action-trigger-3

Your action has been created:

ch-script-action-trigger-4

For another Action type in Sitecore Content Hub, you can refer to: Action types

3. Trigger: Sitecore Content Hub provides a trigger to automatically execute an action based on specific events and conditions. Trigger executes on events like create, update, and delete.

To create a Trigger, go to the Content Hub dashboard using the manage icon and click on the Trigger icon:

ch-script-action-trigger-5

It will open a Trigger page window, click on the add New Trigger icon:

ch-script-action-trigger-6

In the trigger detail page, provide the Name, objective, and execution type of the trigger. I am selecting Entity creation and modification events in objective and Execution type as In-background. 

ch-script-action-trigger-7

You can find more details about trigger configuration, objective, and execution type here: Triggers

In the conditions tab click on Add Definition, choose Content (M.Content) then click on the Condition and create a specific condition. Here I am adding the condition if the Content's current life cycle status is in Final, and the Title of the content entity contains Sitecore then only the trigger will execute entity creation and modification. 

ch-script-action-trigger-8

You can find more information about Trigger conditions here: Triggers conditions

Now go to the Action tab, click on the Add action button search for the action we created earlier.

ch-script-action-trigger-9

Click on the save and close button and from a popup window Activate Trigger.

ch-script-action-trigger-10

Your trigger has been created:

ch-script-action-trigger-11

Now your Script, Action, and Trigger are created and to check the Result go to any content entity, edit any field, and click on the save button.

ch-script-action-trigger-12

Go to the Content Hub Script window click on more details, and choose the View logs option:

ch-script-action-trigger-13 ch-script-action-trigger-14

Happy Sitecoreing ðŸ˜Š

Comments

Popular posts from this blog

Sitecore Installation Error: Failed to Start Service 'Sitecore Marketing Automation Engine'

Import CSV Data in Sitecore Using PowerShell: Part-3

Sitecore : The database principal owns a schema in the database, and cannot be dropped message