updateScheduledAction

The updateScheduledAction method changes the schedule for a previously-scheduled event.

Return Value
Promise<{ updatedScheduledActionId: string }>

This method should use the output ID from createScheduledAction to update the time the event should be triggered.

See getScheduledActions for more information on the feature.

Parameters

scheduledActionId

string

ID value that was returned from createScheduledAction.

name

string

Name for the action being scheduled.

documentIds

string[]

A list of document ID values that are to be scheduled. See Document for details.

executeAt

string

ISO formatted string used to determine the time at which the event should be triggered.

userContext

User<UserContext>

See UserContext for details.

Example

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
import type {
  ContentSourceInterface,
  ScheduledAction,
  ScheduledActionActionType,
} from '@stackbit/types'

interface UserContext {
  accessToken: string
}

export class MyContentSource implements ContentSourceInterface<UserContext> {
  async updateScheduledAction({
    scheduledActionId,
    documentIds,
    name,
    executeAt,
    userContext,
  }: {
    scheduledActionId: string
    documentIds?: string[]
    name?: string
    executeAt?: string
    userContext?: UserContext
  }): Promise<{ updatedScheduledActionId: string }> {
    const updateObj = {
      documents: documentIds,
      name,
      executeAt,
    }
    // optionally use userContext.accessToken to update the schedule on the user's behalf
    await this.apiClient.updateScheduledAction(scheduledActionId, updateObj)
    return { updatedScheduledActionId: scheduledActionId }
  }

  // other methods ...
}

Logging

When this method fails, the error is rendered in the UI so that editors receive feedback on the failure.

This method should be implemented alongside the other scheduled action methods: