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

Custom button in a related list to execute 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

Here is my Javascript:
var idstr={!GETRECORDIDS($ObjectType.Opportunity)};
alert(idstr);"{!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.


If you're putting it in a URL you'll have to serialize the array into a string, maybe comma-separated or something.
I got the following to work. It's ugly but works.
var idstr = {!GETRECORDIDS( $ObjectType.Opportunity)};
var url1 = "{!URLFOR($SControl.js2scontrol, Account.Id , null)}" + "&oppIds=" + idstr;
alert(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...