+ Start a Discussion

Pass a parameter to a VF page that's embedded in a standard page layout

I have a VF page that I'm embedding in a standard page layout. I'd like to pass a parameter into the VF page. The VF page's controller will look at the parameter and the current record, then decide what to display on the embedded page.


I have the VF page and controller written. But how can I get the standard page layout editor to pass a parameter in to the VF page? Is that even possible? If not, do you have any other suggestions?




I don't think there is any way to do exactly what you are asking for.


If your only need a few distinct values for this parameter you might consider turning your current page into a custom component with an attribute, then creating a page for each case you need, where each page passes a different parameter value for the attribute.


Alternatively, could you do something with a custom field on the record your page displays?



If I understand correctly, you're trying to pass some value from the object on whose detail page you will embed your VF page to the controller. If so:


For embedding a VF page in a standard page, you create the page with the standard controller of that object and get access to all the fields of that object in the extension that you may be writing for custom behaviour as you can't just write a custom controller. Lookup controller extensions in the documentation for more.


Thank you for the responses. I'm starting to think, though, that I really can't do what I want to.


I have an object that has several custom fields whose values are computed by a potentially long-running batch process. On the standard view page (using a standard page layout), instead of always displaying the value of each field, I'd like to first check whether the batch process is running, and if it is, display "Values are being calculated." If the batch process isn't running, I'll display the field value.


My thought was to create a VF page that displays this for a single field. The page uses the object's standard controller, so the page can be included in the standard page layout. The page also has a controller extension, which checks whether the batch process is running. (I know how to do that.)  Rather than develop a separate copy of this page for each field,  I'd like to have my page accept a querystring parameter that gives either the name of the field or just the field's current value. The controller extension should determine whether the batch process is running, and then populate a binding variable (which the VF page then displays) with either the current value of the field or the string "Values are being calculated."


Once I have this page implemented, I'll include it on the standard page layout for each of my calculated fields, using different query string values for each field.


The trick here is for the VF page, which is embedded in a standard page layout, to accept a querystring that indicates which field it's being called for. While I can place the VF page on the standard page layout, I can't find a way to get the standard page layout editor pass a querystring parameter into the page. A second problem is that I apparently can't put the same VF page on the same standard page layout more than once. So it appears that there's no way to make my embedded VF page re-usable. I'll have to come up with a separate VF page for each field or find some other approach.


Why don't you create an apex component for the same and then use that repeatedly in your VF page that gets displayed on the detail page? You can pass the field names as attributes to the component and then call the component in your VF page repeatedly passing different field names.


Thanks, Manu. That would work, but it would have implications on the display. All the fields would have to be displayed together -- I couldn't scatter them throughout the page layout. If the user wants to display them in a different order, I'd have to edit my VF page -- the user couldn't use the page layout editor to re-arrange them.


I just created an Idea for this. If you agree this would be useful, please vote at https://sites.secure.force.com/ideaexchange/ideaList?c=09a30000000D9xt&sort=recent

Hi MJ Khan, Did you find any solution for this one? I have a similar type of scenario. I have two inline VF Pages from some action on the first page I want to display a message on the second page. Any help! Thanks, Rehan
MJ Kahn / OpFocusMJ Kahn / OpFocus

Sorry, no luck. The only parameter that the standard page layout passes into an embedded VF page is the ID of the record.

Is reverse possible? I am trying to pass the data from VF page to  the standard page
Sorry, that's not possible. The embedded page is pretty much stand-alone - it can't communicate with the outer standard page.