Information for: DEVELOPERS   PARTNERS

Scheduling workflow state transitions

The Lightning Scheduler module is a content scheduler component of the Lightning Workflow suite. This collection of modules enables you to extend the Workflows and Content Moderation modules (packaged with Drupal 8 core) to build and customize workflows supporting your organization’s custom content types and publication needs.

With Lightning Scheduler, you can schedule workflow state transitions to take place systematically at a future date and time.

To learn more about the concepts in a Drupal 8 workflow, see Workflows for Drupal 8: Content, Revisions, and Moderation.

Installing Lightning Scheduler

Lightning Workflow’s components, such as Lightning Scheduler, are disabled by default, but can be installed with Composer like any other Drupal modules.

To install Lightning Scheduler in your Drupal code base, use the following Composer commands:

composer config repositories.drupal composer https://packages.drupal.org/8
composer require drupal/lightning_workflow

Note

Acquia Lightning enables Lightning Scheduler by default on the Landing page and Basic page content types packaged with Acquia Lightning, and on any content type with a workflow moderation state applied to it.

Creating a new scheduled transition

To use Lightning Scheduler to create a scheduled transition for newly created content, you must perform the following steps:

  1. Sign in to your website as a user with Administrator or Site builder permissions.
  2. From the Content tab, select +Add content.
  3. Select a content type, enter a title in the Title field, and enter body text in the Body field.
  4. Scroll to Save as and select a moderation state from the list of states, such as Draft, In review, or Published. The state you select will be the state your content exists in when you save it.
  5. To begin scheduling transitions, click the Schedule a status change link.
  6. To the right of Change to, in the moderation state list, select a state your content will transition to such as Draft, In review, Published, or Archived.
  7. To the right of the moderation state list, enter the date to change the moderation state.
  8. To the right of the date field, enter a time when the moderation state must change, and then click Save to save the future-scheduled moderation state.
  9. From the bottom of the page, click Save to save the content node, or click Preview to review your changes before saving.

The entity will change moderation state on the date and at the time you have specified.

Workflows in Lightning Scheduler

The following workflow factors determine the options displayed in the moderation list:

  • Which transitions are available from the current state – Workflow defines available transitions, and the default state. In Acquia Lightning, for example, the default editorial workflow uses Draft as the default state, but the default state varies by workflow.

  • Which transitions you have permissions to use – Content moderation defines editorial transition permissions at People > Permissions > Content moderation where Use <transition-name> transition denotes the permission, for example: Use Create New Draft transition, or Use Send to review transition.

    More than one workflow can define transitions with the same name. The name of the workflow prefixes the relevant permission, for example: Editorial workflow: Use Create New Draft transition, but you can also create a new workflow (Admin > Configuration > Workflow > Workflows) called Tech Review using the same transition name, Tech Review workflow: Use Create New Draft transition.

    The following image displays scheduling a piece of content to be published, and then archived, click the following image to learn more about the React-based content Scheduler:

Lightning Scheduler

Editing an existing scheduled transition

To use Lightning Scheduler to schedule future transition states for existing content, you must perform the following steps:

  1. Sign in to your website as an administrator, and then select the Content tab.
  2. From the list of content, select Edit under the Operations column beside the content you want to edit.
  3. Scroll down to the bottom of the page, and click Schedule a status change. From the list, select a transition state for the content change:
    • Draft
    • In review
    • Published
    • Archived
  4. To the right of Change to, from the moderation state list, select a state your content will transition to such as Draft, In review, Published, or Archived.
  5. To the right of the moderation state list, enter a date the moderation state changes.
  6. To the right of the date field, enter a time when the moderation state changes, and then click Save to save the future-scheduled moderation state.
  7. From the bottom of the page, click Save to save the content node, or click Preview to review your changes before saving.
  8. To create more scheduled transition states, following the last scheduled state, click add another.

The entity will change moderation state on the dates and at the times you have specified.

When creating or editing a scheduled transition, your Scheduler permissions determine the options available from the transition list, for example: Editorial workflow: Schedule Create New Draft transition, or Schedule Send to review transition. The workflow name also prefixes the relevant Scheduler permission.

Scheduler permissions are a separate collection of permissions derived from the workflow permissions discussed in Creating a new scheduled transition.

Important

A scheduled transition is a request, not a promise. To ensure a successful content transition, you must ensure you configure content to the correct state allowing a transition to the desired target state. Lightning Workflow determines the Scheduler transition process. If the transition fails, the Database logging module, logs the failure on your website at /admin/reports/dblog.

Processing scheduled transitions

Lightning Scheduler transitions are processed during cron runs. For more information about cron, see Using scheduled jobs to support your application.

Deleting scheduled transitions

Lightning Scheduler deletes transitions occurring in the past, and shows you transitions scheduled for the future. After a scheduled transition’s date and time passes, the system deletes the transition, but a record remains because Lightning Scheduler creates a new revision. By viewing the content’s revision history, you can see when Scheduler changed the moderation state.