updateRecipe

Updates a specific data prep recipe by ID.

Syntax 

1import { updateRecipe } from 'lightning/analyticsWaveApi';
2updateRecipe({ id: string, recipeObject: RecipeInput }): Promise<Recipe>

Data Prep Recipe API Resource 

1PATCH /wave/recipes/${id}

updateRecipe uses this Data Prep Recipe API resource.

Parameters 

Parameter NameTypeDescriptionRequired?
idStringThe ID of the recipe.Yes
recipeObjectObjectThe recipe to update. Use a Recipe Input resource.Yes

Returns 

  • A Promise object that resolves with the Recipe response.

Usage 

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

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

This button calls the updateRecipe() method.

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