updateReplicatedFields

CRM Analytics 複製データセットの項目のコレクションを ID で更新します。このメソッドは、対象となる複製データセットの項目と提供されたコレクションをマージします。各項目には name 属性が必要で、新しい項目の場合は fieldType 属性も必要です。このメソッドは既存の項目の削除には使用できませんが、項目をスキップできるため、アクティブな複製からこの項目が削除されます。

構文 

1import { updateReplicatedFields } from 'lightning/analyticsWaveApi';
2updateReplicatedFields({ id: string, replicatedFields: ReplicatedFieldCollectionInput }): Promise<ReplicatedFieldCollection>

CRM Analytics API リソース 

1PATCH /wave/replicatedDatasets/${id}/fields

updateReplicatedFields は、この CRM Analytics API リソースを使用します。

パラメータ 

  • id — (必須) 複製データセットの ID。
  • replicatedFields — (必須) 複製データセットの既存の項目にマージする項目のコレクション。Replicated Field Collection Input リソースを使用します。

戻り値 

使用方法 

updateReplicatedFields を使用するには、いくつかの方法があります。たとえば、複製データセットのリストや、各複製データセットの項目を表示できます。

次の例では、複製データセットが含まれるページに更新ボタンを追加します。ページには、namefieldType など、複製データセットの項目の更新または作成に必要な情報についてのフォーム要素が含まれている必要があります。複製データセットの項目を更新すると、lightning/platformShowToastEvent モジュールを使用して、トーストメッセージが表示されます。

1import { LightningElement, api } from 'lwc';
2import { updateReplicatedFields } from 'lightning/analyticsWaveApi';
3import { ShowToastEvent } from 'lightning/platformShowToastEvent';
4
5export default class UpdateReplicatedFields extends LightningElement {
6  @api rdId; // or fetch the ID of the replicated dataset
7  replicatedFields = {
8    "fields" : [
9      { "name" : "Field1","isSkipped" : true }, // Updating this field
10      { "name" : "Field2" } // Leaving this field unchanged
11      { "name" : "Field3", "fieldType" : "text", "label" : "Field Three" } // Adding a new field
12    ]
13  };
14
15  update(event) {
16    updateReplicatedFields({ id: this.rdId, replicatedFields : this.replicatedFields })
17      .then(() => {
18        this.dispatchEvent(
19          new ShowToastEvent({
20            title: 'Success',
21            message: 'Replicated dataset fields updated',
22            variant: 'success'
23          })
24        );
25      })
26      .catch(error => {
27        this.dispatchEvent(
28          new ShowToastEvent({
29            title: 'Error updating replicated dataset fields',
30            message: error.body.message,
31            variant: 'error'
32          })
33        );
34      });
35  }
36}

既存コレクションのすべての項目は、PATCH 要求内に存在する必要があります。更新されない項目では、name が必須です。

Note

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

1<template>
2  <lightning-button
3    label="Update"
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 (コンポーネントリファレンス)」は、以前と同様にコンポーネントライブラリにあります。