You need to sign in to do that
Don't have an account?

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
However, when that S-control gets the arguments (via location.search in Javascript ), it only has:
lid=01r300000000wJ8&enc=UTF-8
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 location.search 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.
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">The "lid" value refers to the S-control that Salesforce displays next, which it does - no problem.
<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">
</form>
However, when that S-control gets the arguments (via location.search in Javascript ), it only has:
lid=01r300000000wJ8&enc=UTF-8
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 location.search 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.
Code:
<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 (http://sfdc.arrowpointe.com/2006/05/05/use-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.
More importantly, your post (http://sfdc.arrowpointe.com/2006/05/05/use-another-s-control-as-a-css-file/)
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:
http://forums.sforce.com/sforce/board/message?board.id=general_development&message.id=5880&query.id=2489#M5880
Update
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
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.
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.
Cheers
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.