Script types

Sitecore Content Hub offers the following script types. All scripts are restricted.

  • User sign-in scripts - User sign-in scripts are executed every time a user logs into the application.

    User sign-in script type
    Warning

    The User sign-in script might lock users out when there are inconsistent user validations in the script or other runtime errors. This includes superusers and administrators. You can resolve this lock-out by de-activating the script using the REST API or SDK.

  • User pre-registration scripts are executed before a new user is created.

    User registration script type
  • User post-registration scripts - User post-registration scripts are executed after a new user is created.

    User registration script type
  • Metadata processing script - Metadata processing scripts are executed every time an asset is processed by the processing worker.

    Metadata processing script type
  • Action scripts - Action scripts are the only script type that can be used by actions and triggers. They are the most commonly used scripts due to their capacity to cover multiple use cases. When used with Triggers, Actions can execute Action scripts either In Process (immediately) or In Background.

    Action script type

    The In Process Action scripts can be executed during multiple phases but should not be used for UI-related interactions or any time consuming operations:

    • Pre-commit - In this phase, Action scripts are executed before the triggering event's execution. For example, if the triggering event is 'Entity modification', the Action script is executed before the entity is modified. Pre-commit Action scripts can be used to populate default values.

      Important

      The Pre-commit phase is the only phase where scripts can modify the event's data.

    • Security - In this phase, Action scripts are executed when the application asserts the triggering user's permissions. Security Action scripts can be used to perform additional security checks and to throw a SecurityException. For example, if the triggering event is 'Entity modification', the Action script is executed when the application asserts that the triggering user is allowed to modify the entity.

    • Validation - In this phase, Action scripts are executed when the application validates the triggering event's data. Validation Action scripts can be used to perform additional validations and to throw a ValidationException. For example, if the triggering event is 'Entity modification', the Action script is executed when the application validates the entity's modified values.

    • Audit - In this phase, Audit Action scripts are executed after the triggering event's data is finalized. Audit Action scripts can be used to log audit messages to internal or external logging systems.

    • Post: - In this phase, Action scripts are executed after the triggering event is finalized.

  • Shared scripts - Shared scripts can be used to maintain and reuse commonly used code in a separate script that can be referenced by one or more scripts of any type.

    Note

    When building a shared script, all dependent scripts (those that reference the shared script) will be rebuilt as well to keep the integrity of the entire dependency chain. The shared script can only be published if all scripts compile successfully.

Best practices

For script type best practices, see Script execution types.

Do you have some feedback for us?

If you have suggestions for improving this article,