Common Interceptor API
Overview
The Interceptor API’s provides default API functions available in each intercepted method. This interface enables various operations and interactions within the pricefx.
- 1 Overview
- 2 API Methods
- 2.1 add
- 2.2 app
- 2.2.1 getCurrentUser
- 2.3 configuration
- 2.3.1 overrideConfig
- 2.3.2 retrieveConfig
- 2.4 crmManager
- 2.4.1 callAndReceive
- 2.4.2 findAccount
- 2.4.3 findAccounts
- 2.4.4 findByQuery
- 2.4.5 getAccountAssociatedValue
- 2.4.6 getAccountAssociationField
- 2.4.7 getCurrentUser
- 2.4.8 getOpportunityAssociatedValue
- 2.4.9 getOpportunityLineItemURL
- 2.4.10 getOpportunityURL
- 2.4.11 getPayload
- 2.4.12 getQuoteAccountReferenceField
- 2.4.13 getSObjectURL
- 2.4.14 getSugarCrmEntityById
- 2.4.15 isAccountPage
- 2.4.16 isOpportunityPage
- 2.4.17 postCall
- 2.4.18 updateCache
- 2.5 fetch
- 2.5.1 customer
- 2.5.2 customerByFilter
- 2.5.3 customerByName
- 2.5.4 customerExtension
- 2.5.5 productById
- 2.5.6 productByLabel
- 2.6 navigate
- 2.7 notify
- 2.8 translate
- 2.9 url
- 2.9.1 getParameters
API Methods
add
Methods for adding new customers and products.
customer
customer: ((customer) => Promise<any>)
Adds a new customer.
Parameters:
customer
: any - Customer Object.
product
product: ((product) => Promise<any>)
Adds a new product to products.
Parameters:
product
: any - Product Object.
Example:
await api.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
Returns the logged-in user.
Example:
configuration
Methods for managing configuration.
overrideConfig
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:
retrieveConfig
Reads values from Pricefx configuration object.
You can use it to get values from feature flags or some other values such as:
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:
crmManager
Enables communication with CRMs in which Pricefx is embedded.
callAndReceive
Triggers postMessage with a message in the window with CRM.
Parameters:
message
: any - Data which will be sent to CRM.
Example:
findAccount
Returns Account from CRM with provided ID.
findAccounts
Returns max 10 Accounts from CRM which contains the value passed into the function.
Parameters:
name
: any - Name of the account.
findByQuery
Finds 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:
getAccountAssociatedValue
Returns the value of the accountAssociatedValue feature flag.
getAccountAssociationField
Returns the value of the accountAssociationField feature flag.
getCurrentUser
Retrieves the current user from the CRM.
getOpportunityAssociatedValue
Returns the value of the opportunityAssociatedValue feature flag.
getOpportunityLineItemURL
Returns a link to the opportunity line items with provided ID. Salesforce only.
Parameters:
externalId
: string - Id of the opportunity.
getOpportunityURL
Returns a link to the opportunity with provided ID. Salesforce only.
Parameters:
externalId
: string - Id of the opportunity.
getPayload
Returns CRM payload. The value of the payload will vary based on CRM used with Pricefx.
Example:
getQuoteAccountReferenceField
Returns the value of the quoteAccountReferenceField feature flag. (Deprecated, use getAccountAssociationField instead)
getSObjectURL
Returns a link of the SObject. Salesforce only.
getSugarCrmEntityById
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:
isAccountPage
Returns true when Pricefx is embedded under an account page in CRM.
Example:
isOpportunityPage
Returns true when Pricefx is embedded under the opportunity page in CRM.
Example:
postCall
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:
updateCache
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:
fetch
Methods for fetching customer and product data.
customer
Fetches a customer by their ID.
Parameters:
customerId
: string - Customer ID.
customerByFilter
Fetches customers based on a custom filter.
Parameters:
customFilter
: string - Criteria.
customerByName
Fetches customers by their name.
Parameters:
customerName
: string - Customer Name.
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
Fetches a product by its SKU.
Parameters:
label
: string - Product sku.
productByLabel
Fetches products by their label.
Parameters:
label
: string - Product label.
navigate
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:
notify
API for displaying notifications.
Methods:
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:
translate
Translates text based on the provided key and parameters.
Parameters:
key
: string - Translation value key.params
: any - Parameters for translation string formatting.
Example:
url
Methods related to URL handling.
getParameters
Retrieves URL parameters.