Interceptor Examples/Use Cases
How to tell if iFrame is in Account or Opportunity Page?
export const quotesDetailSubmitPre = async ({ api }) => {
const isAccountPage = await api.crmManager.isAccountPage();
const isOpportunityPage = await api.crmManager.isOpportunityPage();
if(isAccountPage) {
// Your code
}
if(isOpportunityPage) {
// Your code
}
};
Used API’s: isAccountPage, isOpportunityPage
Get Data from CRM
To get data from a CRM, Pricefx should be placed into CRM system. Currently, Pricefx doesn’t have any possibility to access CRM system data outside the CRM (except PlatformManager).
Use getPayload
export const quotesDetailSubmitPre = async ({ api }) => {
const payload = await api.crmManager.getPayload();
console.log(payload);
};
Returns data from the current CRM page. For example: if getPayload is triggered under account page in Salesforce, getPayload will return all data from that specific account: accountId, accountName and etc.
Used API’s: getPayload
Use Data from getPayload
export const quotesDetailSubmitPre = async ({ quoteAPI, api }) => {
const payload = await api.crmManager.getPayload();
// To find what values exist in payload
// Can be removed later when not needed
console.log(payload);
// If name in payload can be not existing
await quoteAPI.setHeaderValue('label', payload.name || 'Name do not exist in payload');
};
Used API’s: getPayload, setHeaderValue
Change Inputs/outputs in pricefx CLIC Modules
To populate value/result for inputs in Pricefx with interceptor is fairly easy to do. You can change both inputs and outputs values in Pricefx modules.
To do so, you will need to:
Choose interceptor method which has scope
detail
.Add to parameters CLIC API, for example:
quoteAPI
,compensationPlanAPI
or …Inside module write
await quoteAPI.setHeaderValue('label', 'pricefx Pivo a Párek');
. This function will set value in header, but there are also functions for setting header input value, output result and line items inputs.
Full code example for inptus:
Full code example for outputs:
Used API’s: setHeaderInputValue, setHeaderValue, setHeaderOutputResult
Edit Dashboard inputs
Initially, you will not know what inputs dashboard has, so on first run try to console.log dashboard and check what is inside
Save value from the dashboard somewhere as it can be handy in the future
Now let’s fill dashboard inputs with values from CRM
Used API’s: isAccountPage, getPayload
Get Data from Other Object Using FindByQuery
In these examples, we will show how to get data from the Account (but you can get data and from any other object) while iFrame is placed on Opportunity page.
Used API’s: findByQuery, isOpportunityPage, getPayload, setHeaderInputValue
Filter Data in the CLIC Module List
In this example, we will filter rebates, but you can filter any CLIC module.
Used API’s: isAccountPage, isOpportunityPage, getPayload