How to tell if iFrame is in Account or Opportunity Page?
export const quotesDetailSubmitPre = async ({ api }) => { const { crmManager } = api; const isAccountPage = await crmManager.isAccountPage(); const isOpportunityPage = await crmManager.isOpportunityPage(); if(isAccountPage) { // Your code } if(isOpportunityPage) { // Your code } };
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: { crmManager } }) => { const payload = await 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.
Use Data from getPayload
export const quotesDetailSubmitPre = async ({ api: { crmManager } }) => { const payload = await crmManager.getPayload(); // To find what values exist in payload // Can be removed later when not needed console.log(payload); // If name in payload always exist await quoteAPI.setHeaderValue('label', payload.name); // If name in payload can be not existing await quoteAPI.setHeaderValue('label', payload.name || 'Name do not exist in payload'); };
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:
export const quotesDetailOpen = async ({ quoteAPI }) => { await quoteAPI.setHeaderValue('label', 'pricefx Pivo a Párek'); }
export const quotesDetailOpen = async ({ quoteAPI }) => { // Simple inputs await quoteAPI.setHeaderInputValue('ProjectID', 'Some ID'); await quoteAPI.setHeaderInputValue('ProjectName', 'Project Name'); }
export const quotesDetailOpen = async ({ quoteAPI }) => { // Input with configurator await quoteAPI.setHeaderInputValue('Configurator_Documents', { InvoiceMethod: 'Invoice method', OpportunityOwner: 'Name', OpportunityOwnerEmail: 'Email', OpportunityOwnerPhone: 'Phone', OpportunityOwnerTitle: 'Title' }); }
Full code example for outputs:
export const quotesDetailOpen = async ({ quoteAPI }) => { await quoteAPI.setHeaderOutputResult('outputName', 'pricefx Pivo a Párek'); }
For more information regarding CLIC Method Interceptor API, you can find here: CLIC Method Interceptor API
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
export const dashboardsInputsSet = async ({ api, dashboard }) => { console.log(dashboard) return; }
Save value from the dashboard somewhere as it can be handy in the future
Now let’s fill dashboard inputs with values from CRM
export const dashboardsInputsSet = async ({ dashboard, api }) => { // here we are destructuring api // so we wouldn't need to write api in front of methods that we often use // for example: crmManager and notify const { notify, crmManager } = api; // This method return true of false depending on where pricefx currently is running const isAccount = await crmManager.isAccountPage(); // in condition we are checking if dashboard // is with a name of the dashboard which we want to update if (isAccount && dashboard?.uniqueName === 'Dashboard_SoupPricing') { // here we are getting values from CRM const payload = await crmManager.getPayload(); // dashboard is mutable variable, we can modify inputs inside of this variable dashboard.inputs[0].value = { "Customer": payload.AccountNumber }; // We can check if dashboard variable updated as we want console.log("Updated dashboard input:", dashboard.inputs[0]); } if (isAccount && dashboard?.uniqueName === 'Dashboard_PivoPricing') { const payload = await crmManager?.getPayload(); dashboard.inputs[0].value = { "Customer": payload?.AccountNumber, "PivoType": 'Lager' }; console.log("Updated dashboard input:", dashboard.inputs[0]); } // this is what we are returning to the dashboard return { run: 'yes', dashboard }; };