Fixing a CP3 bug where Proactive Chat can't pass Custom Fields to the Chat Landing page

I recently encountered an issue with Proactive Chat in CP that wasted a good 4 hours of my time and resulted in being a bug in the framework. According to Oracle, this should be fixed in Feb 13 SP3... but as a general rule I don't believe anything Oracle says until I see it happen.

In the meantime, there is a fairly easy fix through a simple customization of the ChatServerConnect widget.

This article will describe the bug, and provide details on the interim fix.

The Bug - Proactive Chat can't pass Custom Field values to the Chat Landing Page

This bug makes it impossible to pass Custom Field values from your Proactive Chat syndicated widget to the Chat Landing page.

The issue is that the Chat Landing page (ChatServerConnect widget's logic.js file) expects Incident URL params to be in the following format when passed through the URL:

  • Incident.CustomFields.c.columnName

Instead, Proactive Chat is passing values as incidents.c$columnName (which is how I remember CP2 working)

The Fix - Customize the ChatServerConnect widget

This can be fixed by a slight customization to the ChatServerConnect widget.

Extend the JS of the core ChatServerConnect widget and override the _setMiscellaneousData method. Inside of that method, change the following.

Change


var customField =   this.data.js.customFields[customFieldID],
                    columnName = customField.col_name.split("c$")[1],
                    postedCustomFieldName = "Incident_CustomFields_c_" + columnName,
                    urlCustomFieldName = "Incident.CustomFields.c." + columnName,
                    postedCustomFields = this.data.js.postedCustomFields || {}, 
                    Url = RightNow.Url;

to


var customField =   this.data.js.customFields[customFieldID],
                    columnName = customField.col_name.split("c$")[1],
                    postedCustomFieldName = "Incident_CustomFields_c_" + columnName,
                    urlCustomFieldName = "Incident.CustomFields.c." + columnName,
                    legacyCustomFieldName = "incidents.c$" + columnName,
                    postedCustomFields = this.data.js.postedCustomFields || {}, 
                    Url = RightNow.Url;

Then change

var value = postedCustomFields[postedCustomFieldName] || Url.getParameter(urlCustomFieldName);

to

var value = postedCustomFields[postedCustomFieldName] || Url.getParameter(urlCustomFieldName) || Url.getParameter(legacyCustomFieldName);

Full source code for this modified widget can be found at https://gist.github.com/fishnugget77/6188450

Comments

i have created a custom field (text field) which added on chat launch page with hidden visibility, now i would like to redirect chat to different queue on the basis of custom filed (example if custom field vale = 1 then go to queue A otherwise Queue B), when i manually enter custom field value manually through chat_launch page then chat redirect as expected but passing value through conditional chat doesn't reconanized by business rule, i added custom field in chat workspace to confirm given value is captured or not.

code :

Conditional chat :

function onWidgetLoaded(eventName, args, scope) {
var eo = args[0]; //event object
if (eo.name == 'ConditionalChatLink') {

Zircon - This is a contributing Drupal Theme
Design by WeebPal.