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
sdevelopersdeveloper 

Visualforce Page Insert with Field Sets

Hello Everyone,

 

I've decided to make a dynamic layout for the Account Edit page along with a dynamic visualforce insert for the Account Detail.  Included in these layouts are two field sets I've created called "Employer"  and "Health Plan".    Basically how it works, is if 'Employer' is selected, the 'Employer' field set is displayed, and if 'Health Plan' is selected, then the 'Health Plan' field set is displayed.  

 

While that all works properly, I've discovered that if I use the salesforce page-layout editor to remove these fields from the general account Detail page, they also stop showing up in the field sets.  So if i want them to be shown on the Edit/Visualforce insert I have to have them at the bottom of the page.  Therefore, they are being shown twice.  Once in my visual force page insert, and also at the bottom of the general record.  Can someone help me so that this doesnt happen?

 

Here is the code for the Account Edit:  (there is obviously code for the rest of the fields in other pageblocksections but i deleted them out to keep this revelent)

 

<apex:page standardController="Account">
      <apex:form >
        <apex:pageBlock title="Account Edit">
              <apex:pageBlockButtons location="both">
                  <apex:commandButton value="Save" action="{!Save}"/>
                  <apex:commandButton value="Cancel" action="{!Cancel}" immediate="true"/>                                
              </apex:pageBlockButtons>
              
                      <apex:pageblocksection title="Account Type">
                      <apex:pageblocksectionitem >
                         <apex:actionRegion >
                          <apex:inputField value="{!Account.EmployerHealthPlan__c}">
                          <apex:actionSupport event="onchange" reRender="ajaxrequest"/>
                          </apex:inputField>
                         </apex:actionRegion>
                      </apex:PageBlockSectionItem>
                  </apex:PageblockSection>
                  
<apex:outputPanel id="ajaxrequest">   
                  <apex:pageBlockSection rendered="{!Account.EmployerHealthPlan__c=='Employer'}" columns="2">
                      <apex:repeat value="{!$ObjectType.Account.FieldSets.Employer}" var="field">
                       <apex:inputfield value="{!Account[field]}">
                        </apex:inputfield></apex:repeat>
                        
                        
                  </apex:pageBlockSection>
                  <apex:pageBlockSection rendered="{!Account.EmployerHealthPlan__c=='Health Plan'}" columns="2">
                                   
                      <apex:repeat value="{!$ObjectType.Account.FieldSets.HealthPlan}" var="field">
                       <apex:inputfield value="{!Account[field]}">  </apex:inputfield></apex:repeat>                    
               </apex:pageBlockSection>
              </apex:outputPanel>     
     
           </apex:pageblocksection>
      </apex:pageBlockSection>
      </apex:pageBlock>
      
</apex:form>
</apex:page>

 Here is the code for Account Detail:

 

<apex:page standardController="Account">
<apex:pageBlock >
                <apex:outputField value="{!Account.EmployerHealthPlan__c}"></apex:outputfield><br></br>
                <apex:outputPanel rendered="{!Account.EmployerHealthPlan__c == null}">No Health Plan recorded yet</apex:outputPanel>
                <apex:outputPanel id="ajaxrequest">   
                  <apex:pageBlockSection rendered="{!Account.EmployerHealthPlan__c=='Employer'}" columns="2">
                    <apex:repeat value="{!$ObjectType.Account.FieldSets.Employer}" var="f">
                       <apex:outputfield value="{!Account[f]}">
                        </apex:outputfield></apex:repeat>
                      
                  </apex:pageBlockSection>
                  <apex:pageBlockSection rendered="{!Account.EmployerHealthPlan__c=='Health Plan'}" columns="2">
                      <apex:repeat value="{!$ObjectType.Account.FieldSets.HealthPlan}" var="f">
                       <apex:outputfield value="{!Account[f]}">
                        </apex:outputfield></apex:repeat>                   
               </apex:pageBlockSection>
              </apex:outputPanel>     
    </apex:pageBlock>
</apex:page>

 

sfdcfoxsfdcfox

I presume you're on Professional Edition? Field Sets honor Field Level Security, which in turn is controlled by Page Layouts in Professional Edition. So, by hiding the fields, you remove their visibility, and the field sets won't work. You will have to override the entire page (so you can leave the fields on the layout), or upgrade to use Custom Profiles/Record Types/Page Layouts, which will unbind Field Level Security from Page Layouts. Contact your account executive.

sdevelopersdeveloper

ok.  thank you for the information!  Guess I'll get to working on a full over-ride then