0

I am trying to run the following script in my Visualforce Page in my Developer Org:

<apex:page controller="SidebarTestController">
<!--<apex:includeScript loadOnReady="true" value="/soap/ajax/29.0/connection.js" />
<apex:includeScript loadOnReady="true" value="/soap/ajax/29.0/apex.js" /> -->
<apex:includeScript loadOnReady="true" value="c.na30.visual.force.com/support/console/39.0/integration.js" />
<script type="text/javascript">

  var callback = function (result) { 
     alert('Testing');
     if (result.success) { 
  alert('Congratulations!');
     }else { 
  alert('something is wrong!');
     }
  };
     function setSidebarVisible() {

       sforce.console.setSidebarVisible(true,sforce.console.Region.LEFT,callback);
  }
</script>
<a HREF="#" onClick="setSidebarVisible();">SetSidebarToExpand</a>

It is relatively straightforward. I am trying to use the setSidebarVisible method discussed here... However, I keep getting the following console printout when loading the page:

Uncaught SyntaxError: Unexpected token <

Subsequently, I get this error:

Uncaught ReferenceError: sforce is not defined

Is this an Issue with the Salesforce Resource? (Is this a Salesforce Bug?) Or do I need to fix something?

0

The URL is probably being resolved as a relative URL (you provided no protocol); the error page can't be parsed as JavaScript, causing the first error. The second error follows: you never imported the correct JavaScript file.

Make sure you're using a canonical path on the current server (start with a leading "/"):

<apex:includeScript loadOnReady="true" value="/support/console/39.0/integration.js" />

Do not use server URLs in your imports, as they are not portable across orgs (e.g. between sandboxes and production).

  • Thank you! I think the version number (39.0 as opposed to 40.0) also had something to do with my problem. – Rooster May 24 '17 at 23:46
  • @Rooster Yeah, 40.0 isn't available globally yet, so that might have not helped if you were using that. I didn't see it in your original question, though. – sfdcfox May 25 '17 at 2:46

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.