---
title: "Set up actions scripts, triggers, and actions"
slug: "set-up-actions-scripts-triggers-and-actions"
abstract: "How to use the action scripts to sort Product Gallery images so they can be retrieved and used by GraphQL."
---
# 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:

1. On the menu bar, click **Manage** :mdiCogOutline:.
2. On the **Manage** page, click **Scripts**.
3. 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*
4. Click **Save**.
5. Next to the action you just added, click the **Enable control** switch to make it active (On).
6. Click the action script just created and then click **Edit**.
7. Paste in the [code](https://doc.sitecore.com/ch/en/users/content-hub/get-removed-asset.html "Get removed asset") for the *Get removed asset* action.
8. Click **Build**.
9. Click **Save** to save your changes.
10. Repeat step 3 to 9 to create the following action scripts. Click the link to see the associated code.
    - [M.Asset - Product Gallery - Save sort order of assets](https://doc.sitecore.com/ch/en/users/content-hub/save-sort-order-of-assets.html "Save sort order of assets")
    - [M.PCM.Product - Product Gallery - Create public links for added assets, store asset sort order](https://doc.sitecore.com/ch/en/users/content-hub/m-pcm-product---product-gallery---create-public-links-for-added-assets,-store-asset-sort-order.md "M.PCM.Product - Product Gallery - Create public links for added assets, store asset sort order")
    - [M.PCM.Product - Product Gallery - Get assets added and put in a property bag](https://doc.sitecore.com/ch/en/users/content-hub/product-gallery---get-assets-added-and-put-in-a-property-bag.html "Product Gallery - Get assets added and put in a property bag")

To add the actions:

1. On the menu bar, click **Manage** :mdiCogOutline:.
2. On the **Manage** page, click **Actions**.
3. Click **New action**.
4. 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*.
5. Click **Save**.
6. 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:

1. On the menu bar, click **Manage** :mdiCogOutline:.
2. On the **Manage** page, click **Triggers**.
3. Click **New trigger**.
4. 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**.
5. 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*.
6. 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**.
7. In the confirmation window, click **OK** to activate the trigger.

To create the *Product Gallery - Save sort order of assets trigger*:

1. On the menu bar, click **Manage** :mdiCogOutline:.
2. On **Triggers** page, click **New trigger**and, 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**.
3. 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*.
4. 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**.
5. In the confirmation window, click **OK** to activate the trigger.