...
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 } }; |
...
Code Block | ||
---|---|---|
| ||
export const quotesDetailSubmitPre = async ({ api: { crmManager } }) => { const payload = await api.crmManager.getPayload(); console.log(payload); }; |
...
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 can be not existing await quoteAPI.setHeaderValue('label', payload.name || 'Name do not exist in payload'); }; |
...
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 }; }; |
...
Code Block | ||
---|---|---|
| ||
export const quotesDetailOpen = async ({ api, quoteAPI }) => { const { crmManager } = api; 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; } |
...
Code Block | ||
---|---|---|
| ||
// First we need to use Method which triggers when we open rebate list export const rebateAgreementsListFilterAdd = async ({ api, filter }) => { const { crmManager } = api; // 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; } |
...