Page-State API for Reading and Writing Properties
For advanced cases, read or write reactive properties on the active business object in the TPM Trade Planning Lightning web component (LWC) with getProperty() and setProperty().
Required Editions
| Available in: Lightning Experience |
| Available in: Enterprise, Unlimited, Einstein 1, and Agentforce 1 Editions with Consumer Goods Cloud Trade Promotion Management |
The TPM Trade Planning LWC (cgcloud-tpm-trade-planning) provides two
@api methods for page state: getProperty() and
setProperty(). Both methods route to whichever business object (BO) is
active, Trade Calendar or Account Plan, so your code never selects a BO. Use the page-state
API for advanced cases that the named action methods, slots, and events don't cover.
Read Properties
Call getProperty() with a property
name to read a reactive property on the active BO. For example,
getProperty('viewName') returns the name of the current view, and
getProperty('isFilterSet') returns true when the filter
has active criteria.
Account Plan properties are read the same way when Account Plan
is the active BO. For example, getProperty('treeData') returns the Account
Plan tree data, including its status in uiStatus.currentStatus. The value
is null until the grid loads.
If the property name doesn't exist on
the active BO, the method throws an error. For example, calling
getProperty('treeData') while Trade Calendar is active throws an error. A return
value of undefined means that the active BO isn't ready yet.
You can read these properties on each business object (BO):
- Trade Calendar:
status,view,viewList,viewName,showFilter,isFilterSet,modifiedView,canAccessPL,hasPromotionCreateAccess,enablePrint,enableCopyPromotion,calcStatus,isGridDirty,promotionList, andpageEARights - Account Plan:
status,view,viewList,viewName,showFilter,isFilterSet,modifiedView,hasPromotionCreateAccess,calcStatus,isGridDirty,downloadingGrid,loadingGrid,treeData,accountPlanDownloadButtonEnabled, andpageEARights
Returned objects and arrays are read-only shared state. Don't change them—copy them first, for example, { ...api.getProperty('view') }.
Write Properties
Call setProperty() with a property
name and a value to write a reactive property on the active BO. Use
setProperty() only for UI-state flags that don't trigger a server
callout, such as showFilter. For any change to server state, use the named
action methods instead.
By default, the TPM Trade Planning LWC batches property-change
notifications with a requestAnimationFrame (rAF) coalescer, so listeners receive the change
on the next animation frame. getProperty() returns the new value
immediately. To notify listeners right away, pass true as the third argument:
setProperty(name, value, true).
This JavaScript sample reads two Trade Calendar properties, opens the filter panel, and
reads an Account Plan property. The getApi() accessor in your custom
wrapper returns the cgcloud-tpm-trade-planning component, which it locates
by data-id. The comments show sample return values.
const api = this.getApi(); // <cgcloud-tpm-trade-planning>, located by data-id
// Read
api.getProperty('viewName'); // 'Atlanta Q4'
api.getProperty('isFilterSet'); // true
// Write a UI-state flag that doesn't drive a callout.
// Pass true as the third argument to notify listeners right away.
api.setProperty('showFilter', true, true);
// Read Account Plan properties only when Account Plan is the active BO
api.getProperty('treeData'); // { uiStatus: { currentStatus: 'VALID' }, ... }
api.getProperty('treeData')?.uiStatus?.currentStatus; // 'VALID'
