Messaging API

Available since version Paper Plane 11.0.

The Pricefx Messaging API allows the external application frontend to interact with Pricefx Pricefx frontend. Via the API you can ask Pricefx to create a new quote, update or fetch quote inputs, etc.

To enable the Messaging API, set the feature flag feIntegration.active to true.

To call Pricefx from the external app frontend, use the window.postMessage() method from JavaScript in the browser.

Example of Pricefx embedded in an external application:

const iframe = document.getElementById('pfx-iframe'); const messageHandler = (event) => console.log(event.data); window.addEventListener(messageHandler); iframe.contentWindow.postMessage({ "source": "pfxParentMessage", "type": "getUserData" }, *);

In this case, you will attach a handler that logs the message it receives from Pricefx, and also will message Pricefx requesting the logged in user data.

 

Example of an external application embedded in Pricefx:

const messageHandler = (event) => console.log(event.data); window.addEventListener(messageHandler); window.parent.postMessage({ "source": "pfxParentMessage", "type": "getUserData" }, *);

The messages must have 2 fields: source and type. For most messages, there will be also the payload field which will contain additional data for the sent message.

  • source refers to the origin of the message, which can be either pfxParentMessage or pfxChildMessage.

  • type defines which kind of message is being sent, and can be any of the following values described in the tables below.

Some kinds of messages will also return data which will be sent through postMessage too.

Note: Messages described in the table below (except for getUserData and addClicLineItems) have the same signature as described here.

The following messages are available for both cases (where Pricefx is either the parent or a child page):

Message type

Payload

Description

Example

Response

Message type

Payload

Description

Example

Response

getUserData

None

Returns the logged in user data.

{ "source": "pfxParentMessage", "type": "getUserData" }

getClicHeaderValue

  • fieldName – The field's name which you would like to retrieve.

Gets a header field’s value from the CLIC, i.e. quote displayed. This is only enabled when a detail page is open.

updateClicHeaderValue

  • fieldName – The field's name which you would like to update.

  • fieldValue – The new value of this field.

Updates a header field’s value. This is only enabled when a detail page is open.

None

recalculate

None

Recalculates the CLIC displayed. This is only enabled when a detail page is open.

None

getClicLineItems

  • queryData – Can be either a query for more complex search or a string with the line item SKU.

Returns the line items matching the given queryData criteria. This is only enabled when a detail page is open.

addClicLineItems

  • lineItems – An array of objects, each of them corresponding to one line item. It has one mandatory sku string field, and an optional object field inputs where it is possible to pass line items inputs values.

Adds a list of SKUs to the current CLIC displayed, with the option of filling some of its inputs. This is only enabled when a detail page is open.

None

 

There are also messages which are exclusive to the case where Pricefx is embedded in an external application, since they manipulate the window location:

Message type

Payload

Description

Example

Response

Message type

Payload

Description

Example

Response

newQuote

newRebateAgreement

newContract

newCompensationPlan

Creates a new quote/RBA/contract/compensation plan.

Values of this new CLIC can be passed through targetPageState which reuses context linking and has the exact same API.

None

navigate

  • targetPage

  • id

Navigates Pricefx to the given target page.

None

 

There are also events in Pricefx that will trigger a message. When submitting or recalculating a CLIC, a message will be sent containing all CLIC data, such as:

 

Found an issue in documentation? Write to us.

Â