Versions Compared

Key

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

...

Table of Contents
minLevel1
maxLevel6
include
outlinefalse
indent
stylenone
exclude
typelist
class
printabletrue

...

API Methods

add

Methods for adding new customers and products.

...

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

Adds a new customer.

Parameters:

  • customer: any - Customer Object.

product

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

Adds a new product to products.

Parameters:

  • product: any - Product Object.

Example:

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

...

Returns the logged-in user.

Example:

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

...

Used to temporarily set a value in the configuration. Updated configuration is valid only in the current web browser tab.

Parameters:

  • path: string - Name of configuration.

  • value: any - Configuration new value.

Example:

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

...

  • type - dev | prod

  • partition

  • applicationEnvironment - standalone | salesforce | c4c | dynamics | sugarCRM

  • apiUrl

  • locale

Parameters:

  • path: string - Name of configuration.

  • defaultValue: any - (Optional) If retrieving the configuration is unsuccessful, the default value will be returned.

Example:

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

...

Triggers postMessage with a message in the window with CRM.

Parameters:

  • message: any - Data which will be sent to CRM.

Example:

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

...

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

Parameters:

  • name: any - Name of the account.

findByQuery

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

Finds opportunities data in CRM’s by SQL query. Supported keywords: SELECT, FROM, WHERE, LIMIT, AND, and OR.
Supported operators for Salesforce, C4C, and Dynamics: =, !=, <, >, <=, >=, LIKE.
Supported operators for SugarCRM: =, LIKE.

Parameters:

  • query: string - Query which will be executed.

Example:

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 api.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>)

...

getAccountAssociatedValue

...

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

Parameters:

  • externalId: string - Id of the opportunity.

getOpportunityURL

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

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

Parameters:

  • externalId: string - Id of the opportunity.

getPayload

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

Returns CRM payload. The value of the payload will vary based on CRM used with Pricefx.

Example:

Code Block
languagejs
export const quotesDetailNew = async ({
  quoteAPI,
  api: { crmManager }
}) => {
  const payload = await api.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);
};

...

Loads an entity by ID from the module. SugarCRM only.

Parameters:

  • module: string - Name of the module.

  • id: string - Id of the object in module.

Example:

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

...

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

Example:

Code Block
languagejs
export const quotesDetailSubmit = async ({
  api
}) => {
  if(await api.crmManager.isAccountPage()) {
    await api.notify.success('We on account page');
  }
};

isOpportunityPage

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

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

Example:

Code Block
languagejs
export const quotesDetailSubmit = async ({
  api
}) => {
  if(await api.crmManager.isOpportunityPage()) {
    await api.notify.success('We on opportunity page');
  }
};

postCall

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

Calls HTTP request in CRM. Salesforce and SugarCRM only.

Parameters:

  • url: string - API call url.

  • method: GET | POST | PUT | DELETE - Method which will be used for API call.

  • payload: any - Body of the API call.

Example:

Code Block
languagejs
export const quotesDetailSubmit = async ({
  quoteAPI,
  api: { crmManager,
notify }
}) => {
  const externalRef = await quoteAPI.getHeaderValue('externalRef');
  const opportunityUrl = await api.crmManager.getOpportunityURL(externalRef);
  const totalValue = await quoteAPI.getHeaderOutputResult('TotalAmount');
  const payloadForSF = {
    PriceFx_Quote_No__c: quoteAPI.getHeaderValue('uniqueName'),
    Amount: totalValue
  };
  api.crmManager.postCall(opportunityUrl, 'PATCH', payloadForSF).then(() => {
    api.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>)

Used This function is used to manipulate _initCache in SugarcrmManager. It is mainly used to modify the parent account under the account page in SugarCRM. SugarCRM only.

Parameters:

  • path: string - Path to Cache.

  • data: any - Data for update.

Example:

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

...

Fetches a customer by their ID.

Parameters:

  • customerId: string - Customer ID.

customerByFilter

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

Fetches customers based on a custom filter.

Parameters:

  • customFilter: string - Criteria.

customerByName

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

Fetches customers by their name.

Parameters:

  • customerName: string - Customer Name.

customerExtension

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

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

Parameters:

  • tableName: string - Name of the Customer Table.

  • filter: string - Advance filter.

productById

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

Fetches a product by its SKU.

Parameters:

  • label: string - Product sku.

productByLabel

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

Fetches products by their label.

Parameters:

  • label: string - Product label.

navigate

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

Allows page navigation using interceptor API. This API uses Context Linking for navigation.

Parameters:

  • targetPage: string - Page to which user should be navigated.

  • targetPageState: any - Additional parameters for navigation.

Example:

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

...

  • alert: Displays a blue notification message.

  • error: Displays a red notification message.

  • info: Displays a blue notification message.

  • success: Displays a green notification message.

  • warning: Displays an orange notification message.

Parameters:

  • message: string - Translation value key.

  • options: {duration?: number, url?: string, urlName?: string} - (Optional) Settings for notification.

Example:

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

...

Translates text based on the provided key and parameters.

Parameters:

  • key: string - Translation value key.

  • params: any - Parameters for translation string formatting.

Example:

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

...

Retrieves URL parameters.

Related Topics

...