createDataflowJob

Creates a CRM Analytics dataflow job, which is the equivalent of clicking Run Now for a data prep recipe, a data sync, or a dataflow in the CRM Analytics Data Manager UI. For more information on the different IDs that are used to start a job, see Run, Schedule, and Sync CRM Analytics Data with REST APIs.

Syntax 

1import { createDataflowJob } from 'lightning/analyticsWaveApi';
2createDataflowJob({ dataflowJob: { DATAFLOWID: string, COMMAND: string } }): Promise<DataflowJob>

CRM Analytics API Resource 

1POST /wave/dataflowjobs

createDataflowJob uses this CRM Analytics API resource.

Parameters 

Parameter NameTypeDescriptionRequired?
dataflowIdStringThe dataflow, data prep recipe, or data sync ID for the job.Yes
commandStringThe job command to execute. Must be start to create a dataflow job.
  • start
  • stop
Yes

Returns 

A Promise object that resolves with the Dataflow Job response.

Usage 

There are several ways to use createDataflowJob. For example, you can display a list of recipes and enable start on each recipe on the list.

This example adds a start button to a page with recipes. Starting a recipe displays a toast message using the lightning/platformShowToastEvent module.

1import { LightningElement, api } from "lwc";
2import { createDataflowJob } from "lightning/analyticsWaveApi";
3import { ShowToastEvent } from "lightning/platformShowToastEvent";
4
5export default class CreateDataflowJob extends LightningElement {
6  @api dfId; // or fetch the dataflowId of the data prep recipe
7  command = "start";
8
9  start(event) {
10    createDataflowJob({
11      dataflowJob: { dataflowId: this.dfId, command: this.command },
12    })
13      .then(() => {
14        this.dispatchEvent(
15          new ShowToastEvent({
16            title: "Success",
17            message: "Recipe Started",
18            variant: "success",
19          }),
20        );
21      })
22      .catch((error) => {
23        this.dispatchEvent(
24          new ShowToastEvent({
25            title: "Error starting recipe",
26            message: error.body.message,
27            variant: "error",
28          }),
29        );
30      });
31  }
32}

This button calls the createDataflowJob() method.

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

Release Preview

This release is in preview. Features described here don't become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can't guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.