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
okaylah52okaylah52 

Custom button in a related list to execute window.open with dynamic parameter

In an Account detail page, I created a custom button in the Opportunity related list to execute Javascript. How can I pass the (string) value of GETRECORDIDS to another s-control when calling window.open()?

Here is my Javascript:
Code:
var idstr={!GETRECORDIDS($ObjectType.Opportunity)};
alert(idstr);
window.open("{!URLFOR($SControl.MySControl, Account.Id, [oppIds=idstr])}","","top=100,left=100,width=400,height=400,status=yes,toolbar=yes");

I get an error indicating "idstr" doesn't exist.

Any help/pointer will be appreciated.

Thanks.

werewolfwerewolf
If you're putting it in a URL you'll have to serialize the array into a string, maybe comma-separated or something.
okaylah52okaylah52
I got the following to work. It's ugly but works.
Code:
var idstr = {!GETRECORDIDS( $ObjectType.Opportunity)};
var url1 = "{!URLFOR($SControl.js2scontrol, Account.Id , null)}" + "&oppIds=" + idstr;
alert(url1);
window.open(url1, "", "top=100,left=100,width=400,height=400,status=yes,toolbar=yes");

On the receiving end (an S-control page), I have to split the oppIds into an array of strings.

Now, I wonder if can do the same thing from executing Javascript to an Apex page...
.