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
MJ09MJ09 

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?

 

Thanks!

aballardaballard

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?

 

md1md1

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.

MJ09MJ09

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.

md1md1

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.

MJ09MJ09

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

rehan_moodrehan_mood
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.

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

Hi,
One way of doing this could be we get the id of the record for which the standard page is displayed. Then using that id, query the data you want to display and show it.

Like suppose you embedded a VF page in case detail page, then to get the id of the current record in your embedded VF page you can use:

String caseId=ApexPages.currentPage().getParameters().get('id');
Using this id, query the case object or any other related object and show data accordingly.

Hope it helps.

MJ Kahn / OpFocusMJ Kahn / OpFocus
Shubham Nandwana, thank you for your reply. I definitely know how to pass the Id of the current record into the VF page and how to query for data related to that record. That's not what I as asking about.

Imagine a scenario where a VF page accepts a parameter "type" and displays two different things depending on whether the value is "a" or "b." Imagine I want to put the VF page on the record page twice, once with parameter "a" and a second time with "b." I was asking if there's any way to do that. (Yes, I know I could split it into 2 separate VF pages, but that's not what I was asking.)

Obviously, with the advent of Lightning Components (which weren't available when I posted my question in 2010), this is now possible using either Aura or LWC. After 10+ years, the answer to my question isn't relevant anymore, except out of curiosity as to whether it was possible.