orderExtensionUtils Service Component

To extract data from orders and push new data into orders, use the orderExtensionUtils service component to hook on the order state.

Required Editions

Available in: Lightning Experience

Available in: Enterprise and Unlimited Editions that have Consumer Goods Cloud enabled

<!-- 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>

Considerations for using the orderExtensionUtils component:

  • If your org has Lightning Web Security enabled, the runtimeNamespace property on the metadata file isn’t required. You must test the Lightning web security feature before it’s enabled. See LWC Security for more information.
  • When you specify a runtimeNamespace in the metadata file, your component can’t access “@salesforce” resources. To perform APEX calls and other actions that require Salesforce modules, use the available functions in the retailGenericUtils module.
  • When your component doesn’t have the runtimeNamespace property set up on the metadata file, the system throws an error. To fix it, add the runtimeNamespace property with the namespace cgcloud to your component.
  • When your component includes other custom components that don’t have the runtimeNamespace property in their metadata file, add the runtimeNamespace property with the namespace cgcloud to all the included components. Also add this property to the child components.