I have been following this guide to Integrate Salesforce using the Streaming API, but I keep get this error "Uncaught TypeError: Cannot call method 'configure' of undefined OpenPriorityPosition?core.apexpages.devmode.url=1:50

I have uploaded the jquery files as a static zip file resource within salesforce and named it jQueryCometD. The only files in the folder are the four files listed above. The code for the page is listed below:

<apex:page >
     <apex:includeScript value="{!$Resource.jquery}"/>
     <apex:includeScript value="{!$Resource.cometd}"/>
     <apex:includeScript value="{!$Resource.json2_js}"/>
     <apex:includeScript value="{!$Resource.jquery_cometd}"/>
<script type="text/javascript">
        $(document).ready(function() {
            // Connect to the CometD endpoint
           configuration = {url:'https://'+window.location.hostname+'/cometd/26.0/',
                            requestHeaders: {
                                "Authorization": "OAuth {!$Api.Session_ID}"
                            appendMessageTypeToURL : false

           // Subscribe to a topic.
           // JSON-encoded update will be returned in the callback               
           //TODO #1: Specify the pushtopic.
           $.cometd.subscribe('/topic/openPriorityPosition', function(message) {
               // Message is a JSON-encoded update passed in the callback
               var position = message.data.sobject;
                    '<br/>' + 'Name: ' + (position.Name) +
                    '<br/>' + 'Location: ' + (position.Location__c) + 

                    //TODO #2: Within the () put a reference to the status of the position
                    '<br/>' + 'Status: ' + (position.Status__c) + 
                    //TODO #3: Within the () put a reference to the priority of the position
                    '<br/>' + 'Priority: ' + (position.Priority__c) + 
  <apex:sectionHeader title="Positions" subtitle="New or Modified High/Critical Priority     Positions"/>
  <apex:pageBlock >
  <apex:pageBlockSection columns="1">
           <apex:pageBlockSectionItem >
              <apex:outputLabel value="Notifications" />
              <apex:outputPanel id="messages" layout="block" />

This is the same code that they used in the Dreamforce class this was listed in, so I don't believe there is problem with the code since there instance rendered fine. I believe there is something wrong were my Salesforce instance isn't calling the API or accessing jQuery properly. If someone could help me out, that would be great. I have tried using jQuery with other examples as well and none of them see to be working. I can obtain the push notifications in the workbench, but nothing renders when I try and add it to a visualforce page.

  • is this outputting the correct URL? {url:'https://'+window.location.hostname+'/cometd/26.0/' – Scott Pelak Feb 28 '14 at 22:29
  • How do I know if it is outputting the right URL? – NewbieDeveloper27 Feb 28 '14 at 22:40
  • i dunno. but the error says its with the "configuration" and your error message has "core.apexpages.devmode.url=1:50" which look to be a url parameter. Do a quick console.log('https://'+window.location.hostname+'/cometd/26.0/') to make sure it looks legit – Scott Pelak Feb 28 '14 at 23:25

I tried the same code which you have and it worked fine for me. I can think of 2 possible reasons.

1) Did you zip and upload the statis resources. I just uploaded the files individually.

2) Did you configure your push topic correctly. You can use https://workbench.developerforce.com


You need to change the <apex:includeScript> lines to reference the jQueryCometD static resource:

 <apex:includeScript value="{!URLFOR($Resource.jQueryCometD, 'jquery.js')}"/>
 <apex:includeScript value="{!URLFOR($Resource.jQueryCometD, 'cometd.js')}"/>
 <apex:includeScript value="{!URLFOR($Resource.jQueryCometD, 'json2.js')}"/>
 <apex:includeScript value="{!URLFOR($Resource.jQueryCometD, 'jquery_cometd.js')}"/>

Note - you may have to change the filenames to match your zip.

Not certain this is the only issue, but that would certainly stop the example from working.

  • On my first try, I changed the includeScript lines to reference exactly what you have above and that came back with a failing 404 error so I changed it to what I have now in my example. – NewbieDeveloper27 Mar 3 '14 at 14:21

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.