Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
stylenone

How to tell if iFrame is in Account or Opportunity Page?

Code Block
languagejs
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).

...

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

Code Block
languagejs
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.

...

For more information regarding CLIC Methid 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

Code Block
languagejs
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

Code Block
languagejs
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
  };
};