Set up actions scripts, triggers, and actions
There are four action scripts along with triggers and actions that are used to sort the Product Gallery images so they can be retrieved and used by the Azure function through GraphQL.
Action scripts
To add the action scripts:
-
On the menu bar, click Manage
.
-
On the Manage page, click Scripts.
-
On the Scripts page, click + Script and, in the Script dialog box, do the following:
-
In the Name field, type M.Asset - Product Gallery - Get removed asset.
-
From the Type list, select Action.
-
In the Description field, type M.Asset - Product Gallery - Get removed asset
-
-
Click Save.
-
Next to the action you just added, click the Enable control switch to make it active (On).
-
Click the action script just created and then click Edit.
-
Paste in the code for the Get removed asset action.
-
Click Build.
-
Click Save to save your changes.
-
Repeat step 3 to 9 to create the following action scripts. Click the link to see the associated code.
To add the actions:
-
On the menu bar, click Manage
.
-
On the Manage page, click Actions.
-
Click New action.
-
In the New action dialog box, define the following:
-
In the Name field, type Product Gallery - Get removed assets.
-
In the Label field, type Product Gallery - Get removed assets.
-
From the Type list, select Action script.
-
In the Script field, type M.Asset - Product Gallery - Get removed asset.
-
-
Click Save.
-
Repeat steps 3 and 4 to create actions for the following:
-
Product Gallery - Get and save sort order of assets
-
Product Gallery - Get changed assets
-
Product Gallery - Create public links for linked assets
-
Triggers
To add triggers:
-
On the menu bar, click Manage
.
-
On the Manage page, click Triggers.
-
Click New trigger.
-
In the New trigger dialog box, on the General tab, define the following:
-
In the Name field, type Product Gallery - Get removed assets.
-
In the Description field, type Product Gallery - Get removed assets.
-
In the Objective field, type Entity Modification.
-
From the Execution type list, select In progress.
-
-
Click the Conditions tab and do the following:
-
From the Add definition field, select Asset (M.Asset).
-
Click + Condition and choose Product Gallery (ProductToGalleryAsset) removed item is not empty.
-
-
Click the Actions tab and do the following:
-
Under Pre-commit actions, click Add action and select M.Asset - Product Gallery - Get removed asset action.
-
Click Save and close.
-
-
In the confirmation window, click OK to activate the trigger.
To create the Product Gallery - Save sort order of assets trigger:
-
On the menu bar, click Manage
.
-
On Triggers page, click New triggerand, in the New trigger dialog box, on the General tab, define the following:
-
In the Name field, type Product Gallery - Save sort order of assets.
-
In the Description field, type Product Gallery - Save sort order of assets.
-
In the Objective field, type Entity Modification.
-
From the Execution type list, select In background.
-
-
Click the Conditions tab and do the following:
-
From the Add definition field, select Asset (M.Asset).
-
Click + Condition and choose Product Gallery (ProductToGalleryAsset) removed item is not empty.
-
-
Click the Actions tab and do the following:
-
Under Post actions, click Add action and select M.Asset - Product Gallery - Save sort order of assets.
-
Click Save and close.
-
-
In the confirmation window, click OK to activate the trigger.