Enable Advanced Pricefx Interceptor Communication with CRMs (Rampur 13.0 and Higher)

This article applies to existing implementations only. All new implementations should contain the executeScript method.

Follow this article if you encounter an error message “executeScript method is not available in the CRM postMessage”.

Starting with version Rampur 13.0, the following steps need to be taken to enable advanced communication with Pricefx interceptors:

Enable Feature useCrmActionsFromUnity

  1. Open Administration > Feature Flags and enable the feature called useCrmActionsFromUnity.

  2. Reload the page.

Salesforce

No action needed.

MS Dynamics

You can find out how to modify/upload the handler by following the steps until step 8 described at Configure Account/Opportunity Integration Unified Interface (Before Rampur 13).

A new switch case should be added on top of the existing ones in the External website handler.

JavaScript
case "executeScript": {
    if (typeof data === "string") {
        const newFunction = new Function(`return (${data})`);
        newFunction()().then((res) => {
            res.action = action
            event.source.postMessage(JSON.stringify(res), event.origin);
        });
    } else {
        console.error("DYNAMICS.eventHandler executeScript: parameter data should be type of string");
    }
    break;
}

SAP C4C

You can find out how to modify/upload the handler at SAP C4C - Mashups.

Add two new functions inside the <script> tag and make sure that it is above PFXMashupCommunication function.

JavaScript
var actionName = '';

function callServiceHandle(data) {
    log('Sending message to mashup iframe with data from executeScript : ' + data);
    sendMessageToMashup({action: actionName, data: JSON.parse(data)});
}

function callServiceErrorHandle(data) {
    log("Error executing script: ", data);
    sendMessageToMashup(data);
}

Find the function PFXMashupCommunication and add a new switch case executeScript and assign an action value from event to variable actionName which we recently added.

JavaScript
var PFXMashupCommunication = function (event) {
  var jsonData = JSON.parse(event.data);
  var action = jsonData.action;
  actionName = action;
  switch (action) {
    case 'executeScript': {
      if (typeof jsonData.data === "string") {
        const newFunction = new Function(`return (${jsonData.data})`)
        newFunction()().then((response) => {
          if (response) {
            response.action = action;
            sendMessageToMashup(response, event.origin);
          }
        });
      } else {
        log("C4C.eventHandler executeScript: parameter data should be type of string");
        sendMessageToMashup({ action }, event.origin);
      }
      break;
    }

SugarCRM

Contact Pricefx Support and request a new Pricefx module.