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
ben_hizakben_hizak 

VF page embedded in layout.

Hi,

I have a VF page, which is embedded (as a URL s-control) in the Contact page layout.

I just want to display some fields (the point is to keep these fields read only).

How do I pass make the VF page know which record's information to display (how do I pass this info, and how do I use it in the VF page side). thanks.

Ben
Best Answer chosen by Admin (Salesforce Developers) 
Gemini@WorkGemini@Work
Here's an example to get you going, MickJ:

I have created a VisualForce page which uses the Case object as a standard controller (see below).  The page is named "CaseMrList", and is designed to show a list of bugs (internally referred to as MRs) associated with that particular case):




Because the VisualForce page uses the Case object as a Standard Controller, I can add this VF page directly to my all Case page layouts.  When I edit a sample Page Layout, and select the Pages view, all VisualForce pages that use the Case standard controller are listed.  You can simply drag those on to the page layout -- the same was as you would do for a S-Control or a custom / standard field. 



Note the <p> next to the left of the field name, signifying it was a Page component (vs. a field or S-Control).

This final screen shows what the field looks like (work in progress, I haven't tuned the CSS yet):




All Answers

David VPDavid VP

In the S-Control Url pass the variable as a merge field. (use ?id='{yourmergefield}' if your page runs on a standardcontroller).

If your VF page has a custom controller you can get to the url var's value via :

ApexPages.currentPage().getParameters().get('...')


-David


jwetzlerjwetzler
Why are you using a URL s-control?  You can use Visualforce pages inline on your page layouts.  Since your page will use the standard controller for that object, you don't have to worry about passing in the id at all, it will be taken care of for you.
MickJMickJ
Can you provide a little more detail on the mechanics of how to do add a VF page into an existing page layout?

I found the following in the wiki but don't really understand what it means: "If you create a VF page that has, say standardController="Account', then you will be able to select 'Pages' as a 'field' to add in your Accounts page layout edit pages. Just drop it anywhere as you would with a normal field. You will have access the account's fields from within your VF page."
Gemini@WorkGemini@Work
Here's an example to get you going, MickJ:

I have created a VisualForce page which uses the Case object as a standard controller (see below).  The page is named "CaseMrList", and is designed to show a list of bugs (internally referred to as MRs) associated with that particular case):




Because the VisualForce page uses the Case object as a Standard Controller, I can add this VF page directly to my all Case page layouts.  When I edit a sample Page Layout, and select the Pages view, all VisualForce pages that use the Case standard controller are listed.  You can simply drag those on to the page layout -- the same was as you would do for a S-Control or a custom / standard field. 



Note the <p> next to the left of the field name, signifying it was a Page component (vs. a field or S-Control).

This final screen shows what the field looks like (work in progress, I haven't tuned the CSS yet):




This was selected as the best answer
SharadSharad

Thanks ! I used the above feature as I had similar requirement but The added VF page is not showing up in edit mode of that page layout. How to make it available in edit mode as well?

 

 

Thanks !

Sharad

SharadSharad

Also, there is one more problem. I added the VF page into a new section in page layout. My VF page looks like

 

<apex:page standardController="Opportunity" tabStyle="Opportunity" action="{!saveFormalBids}" extensions="INTLC_VFExtension_Oppor_Rejection" >

<apex:pageblock >
    <apex:pageBlockSection title="First Bid offered" columns="2">

      <apex:pageBlockSectionItem >
        <apex:outputLabel value="Pricing Treatments" />
        <apex:outputField value="{!formalbids.INTL_Pricing_Treatments1__c}" />   
      </apex:pageBlockSectionItem>

 

    ..........
     
     </apex:pageBlockSection>
</apex:pageblock>
</apex:page>

 

Now the problem is it appears in new page block and when I remove the page block section then it produces an error that pageBlockSection should be included inside pageblock.

 

Can I create just the pageblocksection inside the same Opportunity detail page block by editing page layout?

 

 

Thanks !

Sharad

Trevor0603Trevor0603

JP / Moderator,

 

Can the "Solution" flag be taken off this as it is not a solution and I'm having the same problem with "pure" visual force code below is the example.

 

Page Code

<apex:page standardController="Account" >
<apex:form >
<apex:commandLink value="Copy Address Details" action="{!Save}" id="CopyLink"/>
<apex:inputField value="{!account.name}"/>
</apex:form>
</apex:page>

 

If have then embedded this onto the Account Page Layout just above the address, when it "Detail" mode the fields within the visualforce page are editable but when you choose the edit button of the page they disappear and you are not allowed to "choose/ edit". The code from the standard controller seems to be the wrong way around or is there something within the "page" definition that needs to be updated an attribute or something?

 

 

Regards,

 

Trevor Miller