updateSchedule

Updates the schedule for a CRM Analytics data prep recipe, data sync, or dataflow.

Syntax 

1import { updateSchedule } from 'lightning/analyticsWaveApi';
2updateSchedule({ schedule: { assetId: string, schedule: ScheduleInput } }): Promise<Schedule>

CRM Analytics API Resource 

1PUT /wave/asset/${assetId}/schedule

updateSchedule uses this CRM Analytics API resource.

Parameters 

Parameter NameTypeDescriptionRequired?
assetIdStringThe ID of the dataflow, recipe, or data sync.Yes
scheduleObjectThe schedule to create or update for the dataflow, recipe, or data sync. Use a Schedule Input. Schedules are hourly, daily, weekly, monthly (relative), monthly (specific), and event based.Yes

Returns 

  • A Promise object that resolves with the Schedule response.

Usage 

There are several ways to use updateSchedule. For example, you can display a list of recipes or dataflows and allow the user to update the scheduled run time.

This example adds a schedule button to a page with recipes. Setting the schedule for a recipe displays a toast message using the lightning/platformShowToastEvent module. Note that you should include a UI to enable a user to pick the schedule type and attributes. This example assumes an hourly schedule.

1import { LightningElement, api } from "lwc";
2import { updateSchedule } from "lightning/analyticsWaveApi";
3import { ShowToastEvent } from "lightning/platformShowToastEvent";
4
5export default class UpdateSchedule extends LightningElement {
6  @api assetId; // or fetch the ID of the asset
7  hourlySchedule = {
8    daysOfWeek: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
9    lastHour: 20,
10    hourlyInterval: 3,
11    time: {
12      hour: 2,
13      minute: 30,
14      timeZone: "America/Los_Angeles",
15    },
16    frequency: "hourly",
17  };
18
19  schedule(event) {
20    updateSchedule({ assetId: this.id, schedule: this.hourlySchedule })
21      .then(() => {
22        this.dispatchEvent(
23          new ShowToastEvent({
24            title: "Success",
25            message: "Schedule updated",
26            variant: "success",
27          }),
28        );
29      })
30      .catch((error) => {
31        this.dispatchEvent(
32          new ShowToastEvent({
33            title: "Error updating schedule",
34            message: error.body.message,
35            variant: "error",
36          }),
37        );
38      });
39  }
40}

This button calls the updateSchedule() method.

1<template>
2  <lightning-button
3    label="Schedule"
4    icon-name="utility:date_time"
5    icon-position="right"
6    onclick={schedule}
7  ></lightning-button>
8</template>