How Interceptors Work
This sample of a JavaScript code will be structured like this:
export const compensationsDetailCreateNewRevision = async ({ compensationPlanOriginAPI, compensationPlanNewRevisionAPI, api: { notify }}) => { await notify.success('Triggered interceptor compensationsDetailCreateNewRevision'); // TODO: Add your code }
For each method that should trigger something, there will be a function exported. This function has one argument which has different APIs that will offer interaction with Pricefx, and CLIC data manipulation.
To find the type definitions and documentation of all available methods and their available APIs, click here. If you struggle to find out exactly what is available, you can run a specific interceptor method with a debugger:
export const quotesDetailNew = (parameter) => { debugger; };
PRE and POST Methods
Some methods have both the options – to add PRE and POST code.
The idea behind is that the PRE code will run before the intercepted method, i.e. when you have a PRE method to create a new quote, this will run before the quote is created, and in case your PRE method returns false it will stop and the quote will not be created.
If it returns some value, it is passed to Pricefx and can be used according to the method.
Then, the POST code will run.
PRE and POST methods have the same name, and for PRE ones they must have a Pre suffix.
Example: quotesDetailNew
(POST) and quotesDetailNewPre
(PRE)
How to Edit Interceptor in Pricefx
Available from version 14.0
You can edit Interceptor's code directly from Pricefx.
Go to Administration > Configuration > CRM Integration > Interceptors.
Click Edit interceptor.
The window with the code of the currently Active interceptor will appear.