Loading
學習
目錄
選取篩選

          沒有結果
          沒有結果
          以下是搜尋小祕訣

          檢查關鍵字的拼字。
          使用較常見的搜尋字詞。
          選取較少篩選條件以擴大您的搜尋。

          搜尋所有 Salesforce 說明
          第三方設定程式 UI 元件 JavaScript 檔案

          第三方設定程式 UI 元件 JavaScript 檔案

          每個元件都有 JavaScript 檔案。針對第三方組態器 UI 元件,此檔案包含傳送和接收資料以及與組態器互動的所有邏輯。

          必要版本

          適用於:Lightning Experience
          提供版本:具有 Revenue Cloud Growth 授權或 Revenue Cloud Advanced 授權的 Revenue Cloud EnterprisePerformanceUnlimitedDeveloper Edition

          此 JavaScript 範例使用 Lightning Message Service 事件來傳送和接收資料。

          import {api, LightningElement} from 'lwc';
          
          import {MessageContext, publish} from 'lightning/messageService';
          
          import CONFIGR_CHANNEL from "@salesforce/messageChannel/lightning__productConfigurator_notification";
          
          const LMS_EVENTS = Object.freeze({
              VALUE_CHANGE: "valueChanged",
              NAVIGATE: "navigate",
              CLOSE_PREVIEW: "closePreview",
              TOGGLE_INSTANT_PRICING: "toggleInstantPricing",
              TOGGLE_RULES_VALIDATION: "toggleRulesValidation",
              TOGGLE_COMPACT_LAYOUT: "toggleCompactLayout",
              UPDATE_PRICES: "updatePrices",
              VALIDATE_PRODUCT: "validateProduct",
              CLONE_ITEMS: "cloneItems",
          });
          
          export const STATE_FIELDS = Object.freeze({
              IS_SELECTED: "isSelected",
              QUANTITY: "Quantity",
              ATTRIBUTE_FIELD: "AttributeField",
              PRODUCT_SELLING_MODEL: "ProductSellingModel",
              PRICING_TERM_UNIT: "PricingTermUnit",
              SUBSCRIPTION_TERM: "SubscriptionTerm",
              SELLING_MODEL_TYPE: "SellingModelType",
              PRICE_BOOK_ENTRY: "PricebookEntry",
              IS_DELETED: "Deleted",
              UNIT_PRICE: "UnitPrice",
              CUSTOM_PRODUCT_NAME: "CustomProductName"
          });
          
          export default class MyComponent extends LightningElement {
              
              @api transactionId;
              @api transactionLineId;
              @api currentTransactionLineId;
              @api parentName;
              @api origin;
              @api messages;
              @api header;
              @api optionGroups;
              @api summary;
              @api navigationRoute;
              @api searchInfo;
              @api currencyCode;
              @api transactionRecord;
              @api headerTitle;
              @api isDesignTime;
              // ... do @api annotations for each of the input properties you want from
              // Data Manager
              
              subscription = null; // Stores the subscription to the message service
              
              // Lifecycle hook that subscribes to the message channel when the component is initialized
              connectedCallback() {
                 this.subscribeToMessageChannel();
              }
          
              // Subscribes to the Lightning Message Service channel to receive message
              subscribeToMessageChannel() {
                 if (!this.subscription) {
                     this.subscription = subscribe(
                         this.messageContext,
                         CONFIGR_CHANNEL,
                         (message) => this.handleMessage(message)
                     );
                 }
              }
              
              handleMessage(message) {}
              
              // Send the message to LMS
              sendMessageToDataManager() {
                  const bulkMessagePayload = {
                      action: LMS_EVENTS.VALUE_CHANGE,
                      data: [
                          // Change 1: update the root product's quantity field
                          {
                              key: ["0QLxx0000004jGGGAY"],
                              field: STATE_FIELDS.QUANTITY,
                              value: 100
                          },
                          // Change 2: update the root product's attribute
                          {
                              key: ["0QLxx0000004jGGGAY"],
                              field: STATE_FIELDS.ATTRIBUTE_FIELD,
                              attributeId: "0tjxx0000000001AAA",
                              value: "New Value"
                          },
                          // Change 3: update another one of root product's attributes
                          {
                              key: ["0QLxx0000004jGGGAY"],
                              field: STATE_FIELDS.ATTRIBUTE_FIELD,
                              attributeId: "0tjxx0000000001AAB",
                              value: "0xxxx0000000001AAB"
                          },
                          // Change 4: create a picklist attribute that does not exist (non-defaulted picklist)
                          {
                              key: ["0QLxx0000004jGGGAY"],
                              field: STATE_FIELDS.ATTRIBUTE_FIELD,
                              attributeId: "0tjxx0000000001AAC",
                              value: "0xxxx0000000001AAB"
                          },
                          // Change 5: select a static child product
                          {
                              key: ["0QLxx0000004jGGGAY"],
                              productRelatedComponentId: '0dSxx00000000XtEAI', // the static child PRC to select
                              field: STATE_FIELDS.IS_SELECTED,
                              value: true
                          },
                          // Change 6: select a dynamic option with a child option below it
                          {
                              field: STATE_FIELDS.IS_SELECTED,
                              selectedDynamicOptions: dynamicOptionsForInputPayload,
                              productRelatedComponent: prcForInputPayload
                          },
                          // Change 7: change the PSM for the root product from onetime to termed
                          {
                              key: ["0QLxx0000004jGGGAY"],
                              field: STATE_FIELDS.PRODUCT_SELLING_MODEL,
                              value: {
                                  psmId: "0jPxx00000002JZEAX",
                                  pbeId: "01uxx000000A0tKAAX"
                              }
                          },
                          // Change 8: deselect a child static option
                          {
                              key: ["0QLxx0000004jGGGAY", '0QLxx0000004jGHGAY'],
                              field: STATE_FIELDS.IS_SELECTED,
                              value: false
                          }
                      ]
                  };
          
                  publish(MessageContext, CONFIGR_CHANNEL, bulkMessagePayload);
              }
          }
          
          
           
          正在載入
          Salesforce Help | Article