orderExtensionUtils サービスコンポーネント
注文からデータを抽出し、新しいデータを注文に転送するには、orderExtensionUtils サービスコンポーネントを使用して注文状態をフックします。
必要なエディション
使用可能なインターフェース: Lightning Experience 使用可能なエディション: Consumer Goods Cloud が有効になっている Enterprise Edition および Unlimited Edition |
<!-- CustomComponent.html -->
<template>
<!-- Sample button -->
<lightning-button variant="neutral" label="Update Order Field" onclick={updateOrderFieldValue}></lightning-button>
</template>
<!-- CustomComponent.js -->
import { LightningElement, api } from 'lwc';
import { getOrderData, updateOrderData } from 'cgcloud/orderExtensionUtils';
export default class CustomComponent extends LightningElement {
@api recordId;
initialOrderData = {};
connectedCallback() {
getOrderData(this.recordId).then((data) => {
this.initialOrderData = data;
});
}
// You can invoke this method with the click of a button
updateOrderFieldValue() {
const fieldName = 'cgcloud__Delivery_Note__c';
const newValue = 'test-note';
updateOrderData(this.recordId, this, fieldName, newValue);
}
}
<!-- CustomComponent.js-meta.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>59.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__RecordPage</target>
</targets>
<targetConfigs>
<targetConfig targets="lightning__RecordPage">
<objects>
<object>cgcloud__Order__c</object>
</objects>
</targetConfig>
</targetConfigs>
<runtimeNamespace>cgcloud</runtimeNamespace>
</LightningComponentBundle>
orderExtensionUtils コンポーネントを使用する場合の考慮事項:
- 組織で Lightning Web セキュリティが有効である場合、メタデータファイルの runtimeNamespace プロパティは不要です。Lightning Web セキュリティ機能を有効にする前にテストする必要があります。詳細は、「LWC セキュリティ」を参照してください。
- メタデータファイルに runtimeNamespace を指定すると、コンポーネントは「@salesforce」リソースにアクセスできません。Salesforce モジュールを必要とする APEX コールやその他のアクションを実行するには、retailGenericUtils モジュールで使用可能な関数を使用します。
- コンポーネントのメタデータファイルで runtimeNamespace プロパティが設定されていない場合、エラーが発生します。この問題を解決するには、名前空間が cgcloud の runtimeNamespace プロパティをコンポーネントに追加します。
- コンポーネントに他のカスタムコンポーネント (メタデータファイルに runtimeNamespace プロパティがない) が含まれている場合、名前空間 cgcloud が含まれる runtimeNamespace プロパティを含まれるすべてのコンポーネントに追加します。また、このプロパティを子コンポーネントに追加します。
この記事で問題は解決されましたか?
ご意見をお待ちしております。
