Updates the collection of fields for a CRM Analytics replicated dataset by ID. This method merges the target replicated dataset’s fields with the collection provided. Each field requires the name attribute, and a fieldType attribute is also required if it’s a new field. This method can’t be used to delete existing fields, but they can be skipped, which removes the field from active replication.
There are several ways to use updateReplicatedFields. For example, you can display a list of replicated datasets and the fields for each replicated dataset.
This example adds an update button to a page with replicated datasets. The page must contain form elements for the information required to update or create fields for the replicated dataset, like the name and fieldType. Updating the fields for a replicated dataset displays a toast message using the lightning/platformShowToastEvent module.
1import{LightningElement, api}from 'lwc';2import{updateReplicatedFields}from 'lightning/analyticsWaveApi';3import{ShowToastEvent}from 'lightning/platformShowToastEvent';45export default class UpdateReplicatedFields extends LightningElement{6 @api rdId; // or fetch the ID of the replicated dataset7 replicatedFields = {8 "fields" :[9{"name" : "Field1","isSkipped" : true}, // Updating this field10{"name" : "Field2"}// Leaving this field unchanged11{"name" : "Field3", "fieldType" : "text", "label" : "Field Three"}// Adding a new field12]13};1415 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}
All fields in the existing collection must be present in the PATCH request. For fields that aren’t updated, only the name is required.
Note
This button calls the updateReplicatedFields() method.