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
Jeff C.ax327Jeff C.ax327 

Possible to call an APEX method as an S-Control merge field?

I need to create a button that launches a new url in a separate window.  I need to do some custom coding to properly build the url, i.e., I need to query a couple objects and build the URL from the values returned.  The standard merge fields won't work because the other objects I need info from are not in scope.  Is there any way to call an APEX method as a merge field?
 
Like this?
{! myApexClass.getSpecialUrl( Contact.Id ) }
 
Or... is there a different way I can accomplish this?  I'd rather not use client-side javascript because I don't want to hard-code the window open properties.
 
David VPDavid VP
I haven't tested this but you could try to create a VF page like :


Code:
<apex:page controller="myApexClass" action="{!getSpecialUrl}">

</apex/page>

 Your controller would need to fetch the Contact Id from the url vars like
String cId = ApexPages.currentPage().getParameters().get('contactid');

Make your S-Control bring up the VF page and it will redirect to whatever the getSpecialUrl returns.

Hope this gives you something to work with.


David


Jeff C.ax327Jeff C.ax327
Thank you David, that is a great idea... one that I'm sure I can make work.
 
In my sandbox, I can choose a content source of type "Visualforce Page", but for some reason in production the Visualforce Page option doesn't even show up in the dropdown.  Do I have to enable something somewhere?
 
Jeff
 
David VPDavid VP
I'm glad I could help.

Concerning your question :
Your sandbox will probably be on the cs0 or cs2 server. These are already in Winter09. The Visualforce page as a source for a custom button or link is one of the new features.

You can see on http://trust.salesforce.com/trust/status/#maint when your production will be Winter09 too.
You can create this already in your sandbox and wait until your production is Winter09 to deploy.

If you can't wait that long, you can probably get away with creating a button or link of type 'URL' and use as the URL something like /apex/yourpagename?myvar1={!...}


David