0

The Open CTI Interaction toolkit has a method that a Salesforce Call Center implementation can use for retrieving the Object Name and Record Id of the page that a user is currently on:

sforce.interaction.getPageInfo

When this is called from a native Salesforce page, e.g. a Case detail page, it is populated with information that the Call Center implementation can leverage to, for instance, Log a Call to the appropriate related Case or Opportunity.

For example, from a Case detail page, if I call the following from the JavaScript Console:

sforce.interaction.getPageInfo(function(pageInfo){ console.log(pageInfo.result); });

You get something like the following:

{"url":"https://na11.salesforce.com/500G000000DkCNVIA3?nooverride=1","objectId":"500G000000DkCNV","objectName":"00001262","object":"Case"}

Native Case detail

However, I have overriden the Case "View" Action type with a custom Visualforce Page (requiring that my Visualforce Page uses the Case Standard Controller). When I am viewing this custom Visualforce Case View page, none of this "page info" is properly populated. I get something like this:

"url":"https://skuid.na11.visual.force.com/apex/CaseView?id=500G000000DkCNVIA3&sfdc.override=1","objectId":"","objectName":"","object":""}

Visualforce Case Detail

My question is, is there any way (supported or unsupported) to do the equivalent of a sforce.interaction.setPageInfo (a method which does not exist), so that this information can be populated for Visualforce Pages just as it is for native UI pages?

I have examined the APIs for sforce.interaction, sforce.interaction.cti, and sforce.console, and have not found anything supported or unsupported that provides a way to achieve this.

Here is a link to the Open CTI Developer's Guide for convenience.

1

The reason why getPageInfo doesn't return any page information here is because of the Visualforce override. On a VF page, there might not be any object id, object name or even an object associated with the page.

Conversely, even if there is, the API has no way to understand/ inspect what the "objectid", "object" field on a VF page represents. A custom variable? An salesforce object? Or a wholly unrelated value.

Given this, the getPageInfo doesn't (can't) return the page information of a Visualforce page, since there might be none, or unidentifiable.

However, this same issue also makes getting the page info very easy outside the API! There are several ways to do this - - The easiest is to add the page info as query string params to the page in your VF controller. A lot along the lines of what Jim Rae mentioned. Now you url can look like - {"url":"https://na11.salesforce.com/500G000000DkCNVIA3?nooverride=1&objectid=500G000000DkCNV&objectName=00001262&object=Case","objectId":"","objectName":"","object":""}

You control exactly what information you want returned.

Other ways include the ones described by Jim and html5 post message.

Hope this helps.

  • Gautam, this did not work. I tried passing in the objectId, objectName, and object parameters, all populated correctly, but sforce.interaction.getPageInfo still returns empty values for that information, just as it did before. This is what my console.log of sforce.interaction.getPageInfo returned: {"url":"https://skuid.na11.visual.force.com/apex/CaseView?id=500G000000KZFFjIAP&objectId=500G000000KZFFjIAP&objectName=00001648&object=Case","objectId":"","objectName":"","object":""} – zachelrath Mar 3 '14 at 17:12
0

You could add a custom extension controller to your page and reference it from there.

Change your page tag like this:

<apex:page standardcontroller="Case" extensions="caseExtension">

Then, create an extension controller, thus providing apex based access to your object data. public class myControllerExtension {

private final case mycase;

// The extension constructor initializes the private member
// variable acct by using the getRecord method from the standard
// controller.
public myControllerExtension(ApexPages.StandardController stdController) {
    this.mycase= (Case)stdController.getRecord();
}

public String getCaseID() {
    return mycase.id;
}

}

http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_extension.htm

  • Jim, getting the Id of the Case is not the problem --- as the question indicates, the problem is that OpenCTI is not recognizing that this VF page is not registering itself in the same way that the standard SF detail page is. – zachelrath Mar 3 '14 at 13:06
  • Sorry for the misunderstanding. My thought for this scenario would be to create your own @remote method to return the data you are looking for from your VF page. If you really need something generic (that could use the standard call or not) you could use the standard call, and then in the callback, parse the URL for the "/apex" and if it exists, then call your custom method to build the JSON, otherwise, just use the standard result. – JimRae Mar 3 '14 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.