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

Passing arguments between S-Controls

I'm trying to pass arguments from one S-control to another and finding that only some are going through.
The first S-control passes the arguments using hidden inputs, as shown in this HTML
<form action="/servlet/servlet.Integration" id="importForm" name="importForm" target="_top">
<input type="hidden" name="API_Session_ID" value="{!API_Session_ID}">
<input type="hidden" name="API_Server_URL" value="{!API_Partner_Server_URL_70}">
<input type="hidden" name="lid" value="01r300000000wJ8">
<input type="hidden" name="enc" value="UTF-8">
<input type="hidden" name="CampaignId" value="Unknown">
<input value="Go!" class="btn" type="submit">
The "lid" value refers to the S-control that Salesforce displays next, which it does  - no problem.
However, when that S-control gets the arguments (via in Javascript ), it only has:


I thought something must be wrong in my HTML/Javascript, so I tried a simple test case outside of Salesforce and got all of the arguments in as I expected.  Does anyone know how
arguments could get lost, or perhaps filtered between S-Controls?
I'm also open to any better ideas for passing arguments.

I believe you should be able to reference your other S-Control as you would an external javascript file.  It would be something like:

<script language="javascript" src="/servlet/servlet.Integration?lid=01r300000000wJ8" type="text/javascript"></script>


Then have your form invoke the function from your other s-Control.  This should allow you to access the values from the form.

I have referenced another S-Control as a CSS file (  It should work work for external javascript too.  One of the comments on that page say it does.  Doing this will treat it just like a function you would have within your main S-Control.

Let us know how it goes.

Thanks very much for the quick reply. I have referenced javascript in an S-control successfully in the past.
More importantly, your post (
brings up another challenge that I'll cover below.

I think I'm trying to solve a different problem than what you address. Some additional context should clarify things.
My first S-control populates a select list of campaigns. When one chooses a campaign from the list
and clicks a "Go" button, an event handler puts the selected campaign ID into a hidden input value.
It then submits the containing form to display the next S-control that displays members of the selected campaign. 
I just need to pass the selected campaign ID to the S-control that will display its members.
A URL parameter seems like the best approach, but the second S-Control doesn't get CampaignID.
It gets "lid" and "enc", so I know parameter passing is working, but not for all parameters.
I'm left wondering if Salesforce is filtering URL parameters to servlet.Integration.
If so, I'm back to a refinement of my original question - how can I get a value selected in
one S-control to another S-control for further processing?

Your blog post brings up a bigger question about the linking one S-control to another.
You say the following about using "servlet.Integration?lid=..." references in an S-control:

   "If you are developing something to upload to AppExchange for others to use,
    be careful going this route because the ID of the s-control you reference will be
    different in each Org your package gets downloaded to."

I will eventually put this code on Appexchange and don't want it to break
when someone downloads it. So I'm very interested in any portable way
for one S-Control to refer to another. I checked the discussion boards and
found an interesting post by Mike Shawaluk suggesting a query of the Scontrol
object with the name of the S-control to get the id.  That seems better
than hardcoding lid's in S-controls. Mike's post is at:

I since found that servlet.integration was apparently redirecting my S-control,
changing the lid and losing my passed argument in the process. I changed
the first S-control to get the lid by querying it from the S-control by name.
That apparently avoids the redirection and associated argument loss.

If someone from Salesforce has a better idea or best practices for linking S-controls together
and passing arguments between them, I'm interested.

Message Edited by RichardC on 08-06-2006 05:00 PM

Ron HessRon Hess
You can pass the paramater "eid" , (think: entity ID)  put your campaign ID in there, ( eid=xxxxxxx) and it should be available in the second scontrol.  Note: This paramater is used to pouplate the merge fields in the second scontrol, so you can even use {!Campaign* } in the second scontrol rather than an AJAX query.

from what i've seen the scontrol execution environment is strict and will not pass paramaters other than the three it knows about. (eid,lid,enc)

good luck.
Would you consider using cookies?  Cookies have always been used to preserve state between state-less http requests and are quite simple to use from javascript. 
Thanks for all the replies. I've learned from the best way to link to an S-control from another
is to get it by name by querying the scontrol sobject. If you want to pass an argument to it,
cookies are the safest route. I like Ron's eid suggestion, as long as I'm sure eid gets passed.
Be aware that S-Control names in the current release are not required to be unique!  This will change in the next release, but just wanted to give you a heads up.

In my haste, I created custom fields in the User object to pass values to subsequent
scontrols.  Does anybody see anything particularly fault worthy about taking that approach?
I could add a semaphore field in case the user tries to run the app from different browsers,
but can't think of anything else that might make this a buggy approach.

thanks, David

BTW, storing javascript and css as scontrols has worked beautifully for me.