function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

"Insufficient privileges" trying to invoke one S-Control from another since Winter '07

I have a couple of S-Controls that invoke other S-Controls. Since Winter '07, the invocation fails with "Insufficient privileges." One S-Control submits a form after setting the S-Control and entity IDs
    checklistScontrol = new Scontrol(checklistScontrolName);
    if ( != null)
      document.importForm.lid.value =;
      document.importForm.eid.value = "{!Custom_Object_ID}";      
          <form action="/servlet/servlet.Integration" id="importForm" name="importForm" method="get" onsubmit="handlePersonQuery()"> <!-- target="_top" -->
          <input type="hidden" name="ic" value="1">
          <input type="hidden" name="lid" value="Unknown">
          <input type="hidden" name="eid" value="Unknown">

This worked fine before Winter '07. What has changed to cause this problem, and how do I get around it?

Doug ChasmanDoug Chasman

A number of things have changed in scontrols in Winter '07 and also the Ajax Toolkit included as part of this release is a new animal. I noticed that you are using the ic=1 query param which has only been a part of scontrol urls since Winter '07 and this is definitely something that would not have made sense prior to the latest release. ic=1 turns on some additional behavior (more than just providing auto session id wireup between the scontrol and ajax toolkit layers) that may be causing this.

Development is looking into this now and expects to provide an answer/solution asap.

Have you logged a case with Salesforce support on this already?


Message Edited by Doug Chasman on 01-10-2007 09:56 AM


Thanks for the quick reply. I get the same symptom with or without the ic=1 parameter. I added it hoping that it would fix the problem.

I will log a case with support. In the meantime, if you or anyone else comes up with a way to work around this problem, I would appreciate it.
Doug ChasmanDoug Chasman
Interesting - without the ic=1 the code takes the same path as in the previous release - cool that we've eliminated one variable. Can you try out a few of things:

- if you use the target scontrol inlined in a detail page do you also get the Insufficient Privs error?
- do you have any hard coded object ids in your target scontrol?

what does the code inside of your Scontrol javascript class look like (using the api to lookup the scontrol id based on the scontrol name???)

I don't get Insufficient Privs when inline the scontrol in a detail page.
The target scontrol has no hard coded object ids (I want to avoid them)

The Scontrol class is very simple:
  function Scontrol(scontrolName) {
    this.queryResult = sforceClient.Query("Select Id from Scontrol Where Name = '" + scontrolName + "'");
    if (this.queryResult.className == "QueryResult")
      if (this.queryResult.size == 1)
        { = this.queryResult.records[0].get("Id");
    handle exceptions...
I have verified that this is returning a valid scontrol id.
I also tried setting up a custom link from the detail page to the target scontrol, but the link excludes the extra parameters needed by the scontrol.

Thanks for your attention on this. Let me know if I can provide additional information.


I noticed the code in my last post used the beta Ajax toolkit. I created a simple test case using the Winter '07 Ajax toolkit, and the problem still happens. I included the test case source below. To use it, replace "ActevaRSVP About" in initPage with the name of one of your S-controls. Make sure you get the name right, as I didn't include exception handling. This demonstrates the problem in my instance, even with a simple target - "ActevaRSVP About" is all HTML. Thanks again.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  <script language="javascript" src="/soap/ajax/8.0/connection.js"></script>
  <script id="clientEventHandlersJS" language="javascript">
function initPage() {
    testScontrol = new Scontrol("ActevaRSVP About");
    if ( != null)
      var newURL = "/servlet/servlet.Integration—lid=" +;
      alert("Heading to " + newURL);
      location.href = newURL;
 sforceClient.init("{!API_Session_ID}", "{!API_Partner_Server_URL_70}", true);

  function Scontrol(scontrolName)
    this.queryResult = sforce.connection.query("Select Id from Scontrol Where Name = '" + scontrolName + "'");
    var records = this.queryResult.getArray("records"); = records[0].get("Id");

 <body onload="initPage()">
      <p>If you see this without or after an alert, the test most likely failed.</p>




I took your code for a spin... and from my experimentation, it seems that the function returns the complete 18 character ID.  The url for the s-control only seems to work with the 15 character (upper and lower, obviously) ID.

Shave off the last three characters of the ID before you create the url and I think it ill work.

Doug ChasmanDoug Chasman
michaelforce hit this one on the head (I was on the train and could not answer an was chomping at the bit to as soon as I saw the code). I need to veryfy this but I do not believe this is a change in behavior - regardless its a bug that I'll get fixed asap (you should not have to truncate the last 3 of our object ids to get this to work however as a short term workaround you can do so).

One thing I would suggest is to change your SOQL query to use the new scontrol field DeveloperName instead of Name - DeveloperName is the programatic name for the scontrol and Name maps to the scontrol's label which can be localized and would then break your code.
Doug ChasmanDoug Chasman
FYI - I just verified that this is a new problem in Winter '07, opened a bug on this and I've just finished developing the fix. I'll work with our quality team/release engineering to see about getting this targeted to a patch or e-release asap.

As Doug said, you nailed this. Using only the first 15 characters of the returned ID fixed it.

Thanks for following through with this, and for the tip on using the developer name.
Doug ChasmanDoug Chasman
I will post here as soon as I know when this fix will be deployed to the production site. After the fix is rolled out please remove the workaround of truncating the id to future proof your code :-)

Glad I could help!

Doug, maybe you can make sure I am included in any Apex beta programs or early adoption programs.  :smileywink: :smileywink:


Doug ChasmanDoug Chasman
No problem. BTW I completely missed an opportunity to showcase a new Winter '07 feature here (sort of embarrassing since I wrote it :-): you can now use formula expressions inside merge field blocks and we've added some new functions/globals specifically for scontrols!

You can in most cases isolate yourself from all this url generation and name to id lookup monkey-business altogether, eliminate a round trip to the server for the name to id SOQL query, get point and click support in the scontrol editor, shield your code from internal details like ic=1, etc. Using something like:

{!URLFOR($SControl.YourScontrolsNameHere) }

will produce (specific object id will vary of course):


The situation where this might not be enough is rare (metadata driven system built on top of perhaps).

Message Edited by Doug Chasman on 01-11-2007 08:32 AM

If you are in the neighborhood, you might want to drop by the event on Tuesday:

Otherwise, stay tuned to adn for details.