Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

We have a page layout for a custom object and want to put a Visualforce page as a section in it. However, the height of the content varies, and when I drop the section in, there is a large white space if the content does not fill. How do I deal with this (the part with the big red 'X' through it)?

enter image description here

share|improve this question

1 Answer 1

up vote 5 down vote accepted

Yes it is possible. See the Update - Success at the bottom:

Old Answer - close but not so much

Resizing the VF Page within a Page Layout is not possible though there is an option on the Page Layout that allows scrollbars for the embedded content.

Another option is to (1) make the "embedded" Visualforce Page a Visualforce Component, and (2) write a VF Page similar to:

<apex:page standardController="Your_Object__c">
    <apex:detail subject="{!Your_Object__c.Id}" relatedList="true"/>
    <c:yourComponent recordId="{!Your_Object__c.Id}" />
</apex:page>

Then override the View Standard Button or Link on the Object page with this VF Page.

This option does have some minor downsides in that developers will have to go into the Object from the Setup to change the Page Layout rather than the using the "Edit Layout" link on the top-right. Also Developers will lose the Dev Tools Menu. Again, these are minor issues for Developers, but this could add the functionality you are looking for. It's worth a try.


Update - Success

VF Pages embedded in a Page Layout come over as iframes, so the solution is to write a VF Page using only <apex:detail .../> to bring over the Page Layout and then have JavaScript (via jQuery) resize all the iframes.

Example

<apex:page standardController="Custom_Object__c">
    <apex:detail subject="{!Custom_Object__c.Id}" relatedList="true"/>  
    <apex:includeScript value="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"/>
    <script>
        var j$ = jQuery.noConflict();
        j$("iframe").each(function(){
            j$(this).load(function() {
                j$(this).height( j$(this).contents().find("body").height() );
            });
        });
    </script>
</apex:page>
share|improve this answer
    
Yeah that's a good idea! My only question is: Does this limit my embedded content to only being at the bottom of the page? We need to have it between 2 other sections in the page layout. –  Kristin Aug 6 at 23:03
    
Yes, the content is separate from the Page Layout. To include embedded in the Page Layout, you are stuck with the fixed Height + Scrollbars –  AmatorVitae Aug 6 at 23:04
    
It might be possible to resize the Embedded VF Page in a Page Layout via JavaScript. –  AmatorVitae Aug 6 at 23:10
    
It is possible. See the update :) –  AmatorVitae Aug 6 at 23:24
    
Ok so if I understand this correctly, we're still doing the detail page on top and the resized iframe/vfpage on the bottom? still unable to nest it then? –  Kristin Aug 7 at 1:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.