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
dotnetericdotneteric 

Opening an SControl in a new window from an SControl and passing data to it

I need to open an SControl in a new window from an SControl.  I am using the following code to do this:

window.open("/servlet/servlet.Integration?lid=00bT0000000nyaf&eid=" + OPPORTUNITY_ID, "winLookup", "height=600,width=350,location=no,resizable=yes,toolbar=no,status=no,menubar=no,scrollbars=1");

where "lid" is the id of the SControl I want to open in the new window.  Is there a more practical way to do this?


My other question is, how can I pass information to the SControl in the new window?  I tried inserting additional querystring parameters other than "lid" and "eid", but the additional parameters get stripped out from the querystring.  Any suggestions on how to pass the information to the SControl in the new window?

Thanks in advance.

Message Edited by dotneteric on 06-01-2006 08:34 PM

Ron HessRon Hess
Is there a more practical way to do this?

your method looks practical to me... :smileywink:
"more practical" is often an oxymoron
you can always look into the helper library "js/fucntions.js" that salesforce internal pages use / share, this can be included in your scontrol like this :

Code:
<script language="JavaScript1.2" src="/js/functions.js"></script>

 

can I pass information to the SControl in the new window?

Short answer, No, the execution environment for scontrols strips out paramaters except for eid= and lid=

Long answer, you can create a document in the document tab, and call this as if it were an scontrol.  This file can contain javascript and HTML, you can pass paramaters and see them on the querystring.   You can get the SID from a cookie if you need to connect to the AJAX toolkit.  You will not get any merge fields filled in, since this is not really an SControl.

zachzach
I'm not sure if this is what you're trying to do, but I pass info between s-control screens all the time...  Here's a link that will pop open a new s-control when clicked:

Code:
<a href='/servlet/servlet.Integration—lid=01N300000008g4U&enc=UTF-8&print=n&userarray="+userArray[a][0]+"' target='_blank'>

 

lid is the id of the s-control, 'print=' is a variable that decides whether I want to print the page on load & 'userarray=' is an array of IDs that gets passed to the s-control.  On the other side, I parse out these values as follows:

Code:
 var url = parent.location.href;
 if (url.indexOf('userarray=') != -1){
  var position = (url.indexOf('userarray=')+10);
  for (var a = 0; a < 1000; a++){
   globalIdArray[a] = url.slice(position,position+18)
   position = position+18;
   if (url.charAt(position) != ","){
    break;
   }
   position = position+1;
  }
  printDoc = true;
 } else {
  var user = sforceClient.GetUserInfo();
  globalIdArray[0] = user.userId;
 }

position = url.indexOf('print=')+6;
if (url.charAt(position) == 'y'){
window.print();
} else {}

 

Ron HessRon Hess
nice!

dotnetericdotneteric

If you say this works, then there has to be something I'm not doing right.  When I create a link with additional querystring parameters like you described, they get stripped out.  For example:

<a href='/servlet/servlet.Integration?lid=00bT0000000myjf&eid=006T0000001iliY&enc=UTF-8&testvar=eric' target='_blank'>test</a>

The last parameter, "testvar", will not appear in the querystring in the new scontrol window that opens when I click on the link.

vandervander
hey dotneteric -

i believe what you are doing wrong is that you are trying to access the s-control through a custom link you have created rather than accessing the s-control directly as zach is doing.  for instance, you are creating your s-control and then setting up a custom link on accounts or some other object to access that s-contol.  when you click your custom link, you get the following url end:  /servlet/servlet.Integration?lid=00bT0000000myjf&eid=006T0000001iliY

adding any variable to this url (like the following) will not work as anything besides lid and eid will be ignored and dropped before your s-control is loaded:

/servlet/servlet.Integration?lid=00bT0000000myjf&eid=006T0000001iliY&testvar=eric

what you need to do instead is go to setup > build > custom s-controls > and then select the name of the s-control you are trying to use.  once the page has loaded, look at the url.  it should be something like:

https://<instance>.salesforce.com/<s-control id>

if you copy <s-control id> from the end of this url, you will now be able to access your s-control directly and pass it variables through the url:

/servlet/servlet.Integration?lid=<s-control id>&testvar=eric

this time, testvar will not be ignored or dropped, and will be accessible by your s-control.  hope that helps you out!
dotnetericdotneteric
Hmmm...  That sounds about right...  I will have to revisit this in the near future...  I will reply back and let you know the outcome...
 
Thanks for all the help!!!