# Blueprint actions

> Add custom logic to a blueprint's deployment process with blueprint actions

---

Site [llms.txt](/llms.txt)

---

A blueprint can include one or more *server tiers*. When you need to add custom logic to the deployment process, blueprint actions provide it. Manage them on the **Build** tab of a blueprint's detail view. Remote Script and Copy File actions can be associated with all server tiers, or only specific ones. You can give an action a name and description that make sense for that blueprint, and provide default values for any action inputs.

## Adding a blueprint action

1. Select **Catalog** and select a blueprint.
1. Select **Manage blueprint**.
1. Select the **Build** tab.
1. Select **Action**.
1. Choose an action type and fill out the required information.
1. Select **Save**.

### Enabling and disabling blueprint actions

After an action type is added to a blueprint, enable or disable it using the toggle. Disabled action items do not run when the blueprint is ordered. This is useful for troubleshooting order failures caused by specific actions, and for testing actions that are still in development.

### Reordering blueprint build items

You can reorder blueprint build items by drag-and-drop, with the up/down arrows, or by selecting the order number and entering a new number. The last method is useful when a blueprint has many build items and needs significant reordering.

1. On the blueprint, select the **Build** tab.
    - Use the up and down arrows to move the item to the top or bottom of the list.
    - Use the drag handle (two columns of dots) to drag and drop a build item.
    - Select the order number to reveal an empty order field. Type a number and press Enter to move the item to that position.

![A blueprint Build tab row showing the build item order controls.](/img/cmp/use/blueprints/build/blueprint-actions/reorder-build-items.png)

## Blueprint validation orchestration action

The blueprint validation orchestration action is an order-related process that runs during a blueprint order. This custom script validates fields on specific forms against criteria you define. For example, you could require the hostname field to begin with "00"; any hostname that does not meet this criterion displays an error message when the blueprint is ordered.

<div class="alert alert-info" role="alert">


If you have previously changed the blueprint validation script from the default, you can compare your current script to the latest default and revert to it if desired.
</div>


### Example script

The following example shows an error on the order form when the hostname exceeds 12 characters.

- `[key]` = the desired custom value (for example, an action input name)
- `params_name` = the form name of the action item, in this case, Cluster Provisioning Details

```python
from utilities.logger import ThreadLogger
logger = ThreadLogger(__name__)

from servicecatalog.models import ServiceItem

def validate_order_form(blueprint, profile, group, order_data):
    errors_by_field_id = {}

    params_name = "Cluster Provisioning Details"

    if  blueprint.name != "Test Blueprint -- DONT MODIFY":
        return errors_by_field_id

    service_item_id = f'{order_data[params_name]["service_item"].id}'

    for key, val in order_data[params_name].items():
        if "hostname" == key and len(val) > 12:
            if service_item_id not in errors_by_field_id:
                errors_by_field_id[service_item_id] = {}
            errors_by_field_id[service_item_id][key] = 'Hostname longer than 12 characters'

    return errors_by_field_id
```

## Action types

- [CloudBolt Plugin](/docs/cmp/use/orchestration/plugins/)
- [Remote Script](/docs/cmp/use/orchestration/remote-scripts/)
- [Copy File](/docs/cmp/use/orchestration/actions/file-copy/)
- [External Flow](/docs/cmp/use/orchestration/actions/external-flows/)
- [Webhook](/docs/cmp/use/orchestration/actions/outbound-webhooks/)
- [Email Hook](/docs/cmp/use/orchestration/actions/email-hooks/)
