updateXmd

Updates a specific CRM Analytics user Xmd by dataset ID.

Syntax 

1import { updateXmd } from 'lightning/analyticsWaveApi';
2updateXmd({ datasetId: string, versionId: string, xmd: XmdInput }): Promise<Xmd>

CRM Analytics API Resource 

1PUT /wave/datasets/${datasetId}/versions/${versionId}/xmds/user

updateXmd uses this CRM Analytics API resource.

Parameters 

Parameter NameTypeDescriptionRequired?
datasetIdStringThe ID of the dataset.Yes
versionIdStringThe ID of the dataset version.Yes
xmdTypeStringThe type of the Xmd. The only valid value for update is user.Yes
xmdObjectThe Xmd to update. Use an Xmd Input resource.Yes

Returns 

  • A Promise object that resolves with the Xmd response.

Usage 

Use updateXmd to allow users to change formats for measures and dimensions in a dataset. This example adds an update button to a page with datasets. The page must contain form elements for the information required to update the Xmd for a dataset. Updating an Xmd displays a toast message using the lightning/platformShowToastEvent module.

1import { LightningElement, api } from "lwc";
2import { updateXmd } from "lightning/analyticsWaveApi";
3import { ShowToastEvent } from "lightning/platformShowToastEvent";
4
5export default class UpdateXmd extends LightningElement {
6  @api dId; // or fetch the ID of the dataset
7  @api dvId; // or fetch the ID of the dataset version
8  xmd = {
9    measures: [
10      {
11        conditionalFormatting: {},
12        field: "LastModifiedDate_day_epoch",
13        format: {
14          delimiters: {},
15        },
16        label: "Last Mod Date",
17        showInExplorer: true,
18      },
19    ],
20  };
21
22  update(event) {
23    updateXmd({ datasetId: this.dId, versionId: this.dvId, xmd: this.xmd, xmdType: "user" })
24      .then(() => {
25        this.dispatchEvent(
26          new ShowToastEvent({
27            title: "Success",
28            message: "Xmd updated",
29            variant: "success",
30          }),
31        );
32      })
33      .catch((error) => {
34        this.dispatchEvent(
35          new ShowToastEvent({
36            title: "Error updating Xmd",
37            message: error.body.message,
38            variant: "error",
39          }),
40        );
41      });
42  }
43}

This button calls the updateXmd() method.

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