updateRecipe

特定のデータプレップレシピを ID で更新します。

構文 

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

データプレップレシピ API リソース 

1PATCH /wave/recipes/${id}

updateRecipe は、このデータプレップレシピ API リソースを使用します。

パラメータ 

  • id — (必須) レシピの ID。
  • recipeObject — (必須) 更新するレシピ。Recipe Input リソースを使用します。

戻り値 

  • Recipe 応答を使用して解決される Promise オブジェクト。

使用方法 

ユーザは、updateRecipe を使用することで、ライセンスや表示ラベルなどを変更できます。次の例では、レシピが含まれるページに更新ボタンを追加します。ページには、レシピの更新に必要な情報についてのフォーム要素が含まれている必要があります。レシピを更新すると、lightning/platformShowToastEvent モジュールを使用して、トーストメッセージが表示されます。

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}

このボタンは、updateRecipe() メソッドをコールします。

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>

The Japanese Summer '24 guide is now live

日本語の Summer '24 ガイドが公開されました! 「Component Reference (コンポーネントリファレンス)」は、以前と同様にコンポーネントライブラリにあります。