updateDataset

Updates a specific CRM Analytics dataset by ID.

Syntax 

1import { updateDataset } from 'lightning/analyticsWaveApi';
2updateDataset({ datasetIdOrApiName: string, dataset: DatasetInput }): Promise<Dataset>

CRM Analytics API Resource 

1PUT /wave/datasets/${datasetIdOrApiName}

updateDataset uses this CRM Analytics API resource.

Parameters 

Parameter NameTypeDescriptionRequired?
datasetIdOrApiNameStringThe ID or API name of the dataset.Yes
datasetObjectThe dataset to update. Use a Dataset Input resource.Yes

Returns 

  • A Promise object that resolves with the Dataset response.

Usage 

Use updateDataset to allow users to change descriptions, labels, and more. This example adds an update button to a page with datasets. The page must contain form elements for the information required to update the dataset. Updating a dataset displays a toast message using the lightning/platformShowToastEvent module.

1import { LightningElement, api } from "lwc";
2import { updateDataset } from "lightning/analyticsWaveApi";
3import { ShowToastEvent } from "lightning/platformShowToastEvent";
4
5export default class UpdateDataset extends LightningElement {
6  @api dId; // or fetch the ID of the dataset
7  dataset = {
8    label: "Updated dataset",
9  };
10
11  update(event) {
12    updateDataset({ datasetIdOrApiName: this.dId, dataset: this.dataset })
13      .then(() => {
14        this.dispatchEvent(
15          new ShowToastEvent({
16            title: "Success",
17            message: "Dataset updated",
18            variant: "success",
19          }),
20        );
21      })
22      .catch((error) => {
23        this.dispatchEvent(
24          new ShowToastEvent({
25            title: "Error updating dataset",
26            message: error.body.message,
27            variant: "error",
28          }),
29        );
30      });
31  }
32}

This button calls the updateDataset() method.

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