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
Stacey McDonaldStacey McDonald 

Visualforce Page Help

Using some examples I have come up with the following Visualforce page on our accounts.  I have a few issue with it that I need some help on.
  1. The page is cut off at the bottom when added to the Account Details page.
  2. Clicking the Save button in the page does save the inputField changes but it tries to display the entire Salesforce.com window in the Apex page.
  3. Is there a way to only display this based on a checkbox being checked?
<apex:page standardController="Account" showHeader="true">
    <!-- Define Tab panel .css styles -->
    <style>
    .activeTab {background-color: #236FBD; color:white; background-image:none}
    .inactiveTab { background-color: lightgrey; color:black; background-image:none}
    </style>
            
    <!-- Create Tab panel -->
    <apex:tabPanel switchType="client" selectedTab="name1" id="AccountTabPanel"
        tabClass="activeTab" inactiveTabClass="inactiveTab">
        <apex:tab label="Contact Penetration" name="name1" id="tabOne">
               <apex:pageBlock >
                  <apex:pageBlockSection columns="3">
                    <apex:outputField value="{!account.Architect_Contacts__c}"/>
                    <apex:outputField value="{!account.Design_Contacts__c}"/>
                    <apex:outputField value="{!account.Total_Contacts__c}"/>
                    <apex:outputField value="{!account.Architects_Engaged_6_Months__c}"/>
                    <apex:outputField value="{!account.Designers_Engaged_6_Months__c}"/>
                    <apex:outputField value="{!account.Total_Engaged_6_Months__c}"/>
                    <apex:outputField value="{!account.Architect_Penetration__c}"/>
                    <apex:outputField value="{!account.Design_Penetration__c}"/>
                    <apex:outputField value="{!account.Total_Penetration__c}"/>
                 </apex:pageBlockSection>
              </apex:pageBlock>
        </apex:tab>
        <apex:tab label="Specification Share of Wallet" name="name2" id="tabTwo">
            <apex:form >
               <apex:pageBlock >
               <apex:pageBlockButtons >
               <apex:commandButton action="{!save}" value="Save" immediate="true"/>
               </apex:pageBlockButtons>
                  <apex:pageBlockSection columns="2">
                    <apex:inputField value="{!account.Total_Annual_Specifications_Number__c}"/>
                    <apex:inputField value="{!account.Total_Annual_Specifications_Sales__c}"/>
                    <apex:inputField value="{!account.Koroseal_Specs_TTM_Number__c}"/>
                    <apex:inputField value="{!account.Koroseal_Specs_TTM_Sales__c}"/>
                    <apex:outputField value="{!account.Share_of_Wallet_Number__c}"/>
                    <apex:outputField value="{!account.Share_of_Wallet_Sales__c}"/>
                 </apex:pageBlockSection>
              </apex:pageBlock>
           </apex:form>
        </apex:tab>
        <apex:tab label="Specification Win Rate" name="name3" id="tabThree">
            <apex:form >
               <apex:pageBlock >
               <apex:pageBlockButtons >
               <apex:commandButton action="{!save}" value="Save" immediate="true"/>
               </apex:pageBlockButtons>
                  <apex:pageBlockSection columns="1">
                    <apex:outputField value="{!account.Koroseal_Specs_TTM__c}"/>
                    <apex:inputField value="{!account.Specifications_Won__c}"/>
                    <apex:inputField value="{!account.Specifications_Lost__c}"/>
                    <apex:outputField value="{!account.Specification_Win_Rate__c}"/>
                 </apex:pageBlockSection>
              </apex:pageBlock>
           </apex:form>
        </apex:tab>
    </apex:tabPanel>
</apex:page>
Thanks in advance!
 
Best Answer chosen by Stacey McDonald
William LópezWilliam López
Hello Stacey,

You need to change couple of things.

1) Remove the immediate save, so it will perform a regular save.

Change this
<apex:commandButton action="{!save}" value="Save" immediate="true"/>
For this
<apex:commandButton action="{!save}" value="Save"/>

2) You need to have a single form in the page, if not you can have issues. thefore move the form tag right to the top

User-added image

3) By default the save action return to the record detail page. To prevent that you have several options

A) Overide the view page detail. Here is an example how to do that: (this will overide the view page for all snearios)
https://www.salesforce.com/docs/developer/pages/Content/pages_quick_start_tabs.htm

B) Add a url parameter to tell the SAVE action where to return after saving.

The URl will look like this:

https://c.na9.visual.force.com/apex/DemoTabPageAccount?Id=001E000000JAKT4&retURL=%2Fapex%2FDemoTabPageAccount%26Id=001E000000JAKT4

User-added image

Here is an explanation how this parameter works:
http://raydehler.com/cloud/clod/salesforce-url-hacking-basics-with-returl-saveurl-and-cancelurl.html

Most important its to use the proper URL encoding
http://www.w3schools.com/tags/ref_urlencode.asp

C) Other option its to add an small Apex class controller extension, with that class you can control the redirection.
Here is a good example using the Save action
http://salesforce.stackexchange.com/questions/4041/difference-between-controller-and-extensions

Please let me know how it goes.

Regards.
​Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.  

All Answers

William LópezWilliam López
Hello Stacey,

You need to change couple of things.

1) Remove the immediate save, so it will perform a regular save.

Change this
<apex:commandButton action="{!save}" value="Save" immediate="true"/>
For this
<apex:commandButton action="{!save}" value="Save"/>

2) You need to have a single form in the page, if not you can have issues. thefore move the form tag right to the top

User-added image

3) By default the save action return to the record detail page. To prevent that you have several options

A) Overide the view page detail. Here is an example how to do that: (this will overide the view page for all snearios)
https://www.salesforce.com/docs/developer/pages/Content/pages_quick_start_tabs.htm

B) Add a url parameter to tell the SAVE action where to return after saving.

The URl will look like this:

https://c.na9.visual.force.com/apex/DemoTabPageAccount?Id=001E000000JAKT4&retURL=%2Fapex%2FDemoTabPageAccount%26Id=001E000000JAKT4

User-added image

Here is an explanation how this parameter works:
http://raydehler.com/cloud/clod/salesforce-url-hacking-basics-with-returl-saveurl-and-cancelurl.html

Most important its to use the proper URL encoding
http://www.w3schools.com/tags/ref_urlencode.asp

C) Other option its to add an small Apex class controller extension, with that class you can control the redirection.
Here is a good example using the Save action
http://salesforce.stackexchange.com/questions/4041/difference-between-controller-and-extensions

Please let me know how it goes.

Regards.
​Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.  
This was selected as the best answer
Pankaj_GanwaniPankaj_Ganwani
Hi,

To remove cut off of page, you can increase the size of the inline vf page by going to the edit page layout.
Stacey McDonaldStacey McDonald
Thanks for all of the info very helpful!
nishad basha 7nishad basha 7
Hi ,William López
my requirement is   select any object and click query button and  display  records and with Dynamic SOQL query .How to solve this one please can you help me.
nishad basha 7nishad basha 7
Hi, bob_buzzard

           my requirement is   select any object and click query button and  display  records and with Dynamic SOQL query .How to solve this one please can you help me.