...
Code Block | ||
---|---|---|
| ||
export const quotesDetailSubmitPre = async ({ api }) => { const { crmManager } = 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).
...
Code Block | ||
---|---|---|
| ||
export const quotesDetailSubmitPre = async ({ api: { crmManager } }) => { 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
Code Block | ||
---|---|---|
| ||
export const quotesDetailSubmitPre = async ({ api: { crmManager }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 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'); }; |
Used API’s: getPayload, setHeaderValue
Change Inputs/outputs in pricefx CLIC Modules
...
Code Block | ||
---|---|---|
| ||
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 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
...
Code Block | ||
---|---|---|
| ||
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 api.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 api.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 api.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 }; }; |
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.
Code Block | ||
---|---|---|
| ||
export const quotesDetailOpen = async ({ api, quoteAPI }) => {
const isOpportunityPage = await api.crmManager.isOpportunityPage();
// First let's check if interceptor is running under opportunity page
if(isOpportunityPage) {
// Now we need data from Opportunity page
const payload = await api.crmManager.getPayload();
// Now using payload and string formating
// create query which we will run in Salesforce.
// In this query we are geting all fields from account where id is equel to id
// from what we have under this opportunity page and also
// we added limit 1 so it wouldn't search for other account as only one account
// should exist with this id.
const query = `
SELECT *
FROM Account
WHERE Id = ${payload.AccountId}
LIMIT 1
`;
// now lets execute this query
const accounts = await api.crmManager.findByQuery(query);
// using console.log you can find what is inside
console.log(accounts)
// we need to test is we found any account
if(accounts.length > 0) {
const account = accounts[0];
// now lets set input value in pricefx using data from account
await quoteAPI.setHeaderInputValue('AccountNumber', account.AccountNumber);
} else {
console.error('account not found!')
}
}
return;
} |
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.
Code Block | ||
---|---|---|
| ||
// First we need to use Method which triggers when we open rebate list export const rebateAgreementsListFilterAdd = async ({ api, filter }) => { // Let's use payload for make our filter more interesting const payload = await api.crmManager.getPayload(); // Also let's return different filter based on where iFrame is located const isAccountPage = await api.crmManager.isAccountPage(); const isOpportunityPage = await api.crmManager.isOpportunityPage(); if(isAccountPage) { return [{ fieldName: 'additionalInfo1', operator: 'equals', value: payload.AccountNumber }]; } if(isOpportunityPage) { return [{ fieldName: 'additionalInfo2', operator: 'equals', value: payload.OpportunityId }]; } return filter; } |
Used API’s: isAccountPage, isOpportunityPage, getPayload