Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Overview

The Interceptor API’s provides default API functions available in each intercepted method. This interface enables various operations and interactions within the pricefx.

Table of Contents

Table of Contents
stylenone

Properties

add

Methods for adding new customers and products.

customer

Code Block
languagejs
customer: ((customer) => Promise<any>)

Adds a new customer.

product

Code Block
languagejs
product: ((product) => Promise<any>)

...

Code Block
languagejs
await add.product({
  sku: 'KS-2003',
  label: 'Test2',
  unitOfMeasure: 1,
  currency: 'CZK',
  formulaName: 'ActionButtons',
  attribute18: 'A'
});

app

Used for obtaining data from Unity which are not accessible through configuration.

getCurrentUser

Code Block
languagejs
getCurrentUser: (() => Promise<User>)

...

Code Block
languagejs
await app.getCurrentUser()
/*
{
  "version": 2,
  "typedId": 123,
  "loginName": "donatas.ka",
  ...
}
*/

configuration

Methods for managing configuration.

overrideConfig

Code Block
languagetypescript
overrideConfig: ((path, value) => Promise<void>)

...

Code Block
languagejs
await configuration.overrideConfig(
  'applicationEnvironment',
  'salesforce'
);

retrieveConfig

Code Block
languagetypescript
retrieveConfig: ((path, defaultValue?) => Promise<any>)

...

Code Block
languagejs
const visibleDashboards = await configuration.retrieveConfig(
 'customerSpecificFeatureFlag.dashboards.visible.account',
  []
);

crmManager

Enables communication with CRMs in which Pricefx is embedded.

callAndReceive

Code Block
languagetypescript
callAndReceive: ((message) => Promise<any>)

...

Code Block
languagejs
const message = {
  fields: [
    { id: 'name', value: 'New name' },
    { id: 'description', value: 'New description' }
  ]
};
return crmManager.callAndReceive({ action: 'createNewQuote', data: message })

findAccount

Code Block
languagetypescript
findAccount: (() => Promise<any>)

Returns Account from CRM with provided ID.

findAccounts

Code Block
languagetypescript
findAccounts: ((name) => Promise<{ Id: string; Name: string; }[]>)

Returns max 10 Accounts from CRM which contains the value passed into the function.

findByQuery

Code Block
languagetypescript
findByQuery: ((query) => Promise<any>)

...

Code Block
languagejs
export const crmFindOpportunitiesPre = ({
  result,
  searchText,
  api: { crmManager }
}) => {
  const query = `
    SELECT Id, Name, StageName, RecordType.Name
    FROM Opportunity
    WHERE Name = '%${searchText}%'
    LIMIT 10
  `;
  return crmManager.findByQuery(query).then(list => {
    list.forEach(item => {
      item.Name = `${item.Name} (${item.RecordType.Name})`;
    });
    result.list = list;
    return result;
  });
};

findOpportunitiesByQuery

Code Block
languagetypescript
findOpportunitiesByQuery: ((query) => Promise<any>)

Finds opportunities by SQL. Salesforce only, not implemented in other CRMs.

getAccountAssociatedValue

Code Block
languagetypescript
getAccountAssociatedValue: (() => Promise<any>)

Returns the value of the accountAssociatedValue feature flag.

getAccountAssociationField

Code Block
languagetypescript
getAccountAssociationField: (() => Promise<string>)

Returns the value of the accountAssociationField feature flag.

getCurrentUser

Code Block
languagetypescript
getCurrentUser: (() => Promise<CrmUser>)

Retrieves the current user from the CRM.

getOpportunityAssociatedValue

Code Block
languagetypescript
getOpportunityAssociatedValue: (() => Promise<any>)

Returns the value of the opportunityAssociatedValue feature flag.

getOpportunityLineItemURL

Code Block
languagetypescript
getOpportunityLineItemURL: ((externalId) => Promise<string>)

Returns a link to the opportunity line items with provided ID. Salesforce only.

getOpportunityURL

Code Block
languagetypescript
getOpportunityURL: ((externalId) => Promise<string>)

Returns a link to the opportunity with provided ID. Salesforce only.

getPayload

Code Block
languagetypescript
getPayload: (() => Promise<any>)

...

Code Block
languagejs
export const quotesDetailNew = async ({
  quoteAPI,
  api: { crmManager }
}) => {
  const payload = await crmManager.getPayload();
  await quoteAPI.setHeaderValue('label', payload.Name);
  await quoteAPI.setHeaderInputValue('Customer', payload.Customer_Number__c);
  await quoteAPI.setHeaderInputValue('ProjectID', payload.Project_Id__c);
  await quoteAPI.setHeaderInputValue('ProjectName', payload.Project__c);
};

getQuoteAccountReferenceField

Code Block
languagetypescript
getQuoteAccountReferenceField: (() => Promise<string>)

Returns the value of the quoteAccountReferenceField feature flag. (Deprecated, use getAccountAssociationField instead)

getSObjectURL

Code Block
languagetypescript
getSObjectURL: (() => Promise<string>)

Returns a link of the SObject. Salesforce only.

getSugarCrmEntityById

Code Block
languagetypescript
getSugarCrmEntityById: ((module, id) => Promise<any>)

...

Code Block
languagejs
const parentAccount = await crmManager.getSugarCrmEntityById('Accounts', parentId);

isAccountPage

Code Block
languagetypescript
isAccountPage: (() => Promise<boolean>)

Returns true when Pricefx is embedded under an account page in CRM.

isOpportunityPage

Code Block
languagetypescript
isOpportunityPage: (() => Promise<boolean>)

Returns true when Pricefx is embedded under the opportunity page in CRM.

postCall

Code Block
languagetypescript
postCall: ((url, method, payload) => Promise<any>)

...

Code Block
languagejs
export const quotesDetailSubmit = async ({
  quoteAPI,
  api: { crmManager, notify }
}) => {
  const externalRef = await quoteAPI.getHeaderValue('externalRef');
  const opportunityUrl = await crmManager.getOpportunityURL(externalRef);
  const totalValue = await quoteAPI.getHeaderOutputResult('TotalAmount');
  const payloadForSF = {
    PriceFx_Quote_No__c: quoteAPI.getHeaderValue('uniqueName'),
    Amount: totalValue
  };
  crmManager.postCall(opportunityUrl, 'PATCH', payloadForSF).then(() => {
    notify.success('Opportunity was updated.');
  });
};

reportOpportunityNumberOfQuotes

Code Block
languagetypescript
reportOpportunityNumberOfQuotes: (() => Promise<void>)

Sends the number of quotes back to SugarCRM. (Deprecated)

updateCache

Code Block
languagetypescript
updateCache: ((path, data) => Promise<void>)

...

Code Block
languagejs
// Data is a parent account for the current account
crmManager.updateCache('sugarCRMData.payload.Account', data)

fetch

Methods for fetching customer and product data.

customer

Code Block
languagetypescript
customer: ((customerId) => Promise<Customer>)

Fetches a customer by their ID.

customerByFilter

Code Block
languagetypescript
customerByFilter: ((customFilter) => Promise<Customer[]>)

Fetches customers based on a custom filter.

customerByName

Code Block
languagetypescript
customerByName: ((customerName) => Promise<Customer[]>)

Fetches customers by their name.

customerExtension

Code Block
languagetypescript
customerExtension: ((tableName, filter) => Promise<CustomerExtension[]>)

Fetches customer extension data based on the table name and filter.

productById

Code Block
languagetypescript
productById: ((sku) => Promise<any>)

Fetches a product by its SKU.

productByLabel

Code Block
languagetypescript
productByLabel: ((label) => Promise<Product[]>)

Fetches products by their label.

navigate

Code Block
languagetypescript
navigate: ((targetPage, targetPageState) => Promise<void>)

...

Code Block
languagejs
export const quotesListDataLoad = async ({ api, appPages }) => {
  await api.navigate(appPages.QC_NEW_QUOTE, { id: 'P-123' });
}

notify

API for displaying notifications.

...

Code Block
languagejs
await api.notify.error(
  'Error message, with help link',
  {
    urlName: "help",
    url: "<https://help.me>",
    duration: 0
  }
)

translate

Code Block
languagetypescript
translate: ((key, params?) => Promise<string>)

...

Code Block
languagejs
await api.translate(
  'unity_interceptor_already_exists',
  {
    name: 'myInterceptor'
  }
)

url

Methods related to URL handling.

getParameters

Code Block
languagetypescript
getParameters: (() => Promise<string>)

Retrieves URL parameters.

Related Topics