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 

Visual Force Page and General Fields

Hello,

 

For the general Account Page, rather than writing the apex code out to recreate one section, I inserted a visualforce page in the layout.  This way I can have an entire section that changes based on pick-list values.  However, I want to remove those fields from the general layout (since they're on the Visualforce insert) but when I take them off, they dissapear from everywhere completely.  Is there a way to simply hide the fields or stop this from happening?  Or do I have to rewrite the code for the entire Account page?

 

 

joshbirkjoshbirk

Is the field on any other layout?

sdevelopersdeveloper

Just on the General Account Page display and the Account Edit Page

joshbirkjoshbirk

So are they disappearing on the VF component, or is the issue at hand that they're a) no longer on the edit page and b) the VF component doesn't appear on the edit screen?

sdevelopersdeveloper

they dissapear on the edit and the visual force page

joshbirkjoshbirk

Not sure why they would disappear on the VF page itself, sounds more like an FLS or profile thing.  However, more germaine - no, you can't have a VF component on the edit page, despite what might be on your layout.  You'd need a full VF overrride on the edit page.

sdevelopersdeveloper

Yes my Edit page I have already completely re-written..the problem exists on the regular Account Detail page

joshbirkjoshbirk

Can you post some of the relevant code?  You should be able to keep the VF page embedded on the standard layout, and you can have that edit the current record as well.  For example, I have this:

 

<apex:page StandardController="Book__c">
	
	<apex:form>
	<apex:pageBlock>
	Publish Year: <apex:inputField value="{!Book__c.Publish_Year__c}" /><apex:commandButton value="Update" action="{!quicksave}" />
	</apex:pageBlock>
	</apex:form>
	
</apex:page>

 Removed Publish Year from the layout, and can update Publish Year on the View page.

sdevelopersdeveloper

This is what my Visualforce insert is written as

 

<apex:page standardController="Account">
<apex:form >
        <apex:pageBlock >
                <apex:outputField value="{!Account.EmployerHealthPlan__c}"></apex:outputfield><br></br>
                <apex:outputPanel id="ajaxrequest">   
                  <apex:pageBlockSection rendered="{!Account.EmployerHealthPlan__c=='Employer'}">
                      <apex:outputField value="{!Account.Carrier__c}"/>
                      <apex:outputField value="{!Account.Current_Welness_Vendor__c}"/>
                      <apex:outputField value="{!Account.No_of_Employees__c}"/>
                      <apex:outputField value="{!Account.Data_Vendor__c}"/>
                      <apex:outputField value="{!Account.EE_Enrolled_in_Benefits__c}"/>
                      <apex:outputField value="{!Account.Current_DM_Provider__c}"/>
                      <apex:outputField value="{!Account.Plan_Year__c}"/>
                      
                  </apex:pageBlockSection>
                  <apex:pageBlockSection rendered="{!Account.EmployerHealthPlan__c=='Health Plan'}">
                                   
                      <apex:outputField value="{!Account.Industry}"/>
                      <apex:outputField value="{!Account.Total_Lives__c}"/>
                      <apex:outputField value="{!Account.No_of_Employees__c}"/>
                      <apex:outputField value="{!Account.Total_Enrollment__c}"/>
                      <apex:outputField value="{!Account.No_of_Members__c}"/>
                      <apex:outputField value="{!Account.Fully_Insured__c}"/>
                      <apex:outputField value="{!Account.Sales_Revenue_Potential__c}"/>
                      <apex:outputField value="{!Account.Self_Insure_ASO__c}"/>
                      <apex:outputField value="{!Account.Name_of_the_PBM__c}"/>
                      <apex:outputField value="{!Account.Other_Risk_Type_Unspecified__c}"/>
                      <apex:outputField value="{!Account.Claim_System_Platform__c}"/>
                      <apex:outputField value="{!Account.Medicare__c}"/>
                      <apex:outputField value="{!Account.Key_Executives_Description__c}"/>
                      <apex:outputField value="{!Account.Medicaid__c}"/>                      
               </apex:pageBlockSection>
              </apex:outputPanel>     
    </apex:pageBlock>  
</apex:form>
</apex:page>

 

joshbirkjoshbirk

What's the event flow like?  Because based on that component, unless Employer Health Plan has a default value - you wouldn't see anything on a fresh record.  You'd have to go to the View -> Edit -> Back to View.  Quickedit, for instance, wouldn't effect the component until the view was completely refreshed.

sdevelopersdeveloper

Well this is just an insert in the general display of the full account page.  So if  nothing is selected, yes it is blank.  The rest of the record however is sitll there because it all exists outside of this section

joshbirkjoshbirk

So to be sure VF can or can't see the fields, I'd add something like:

<apex:outputPanel rendered="{!Account.EmployerHealthPlan__c == null}">
No Health Plan recorded yet
</apex:outputPanel>

 At the top.  I think null is correct there, not empty string.  This will give you some feedback what VF thinks the current record state looks like.

 

If that renders, you might add something to refresh the page automagically to detect data changes.

sdevelopersdeveloper

ok thanks!  

 

Do you know of any way that I can make it so I can take the original fields off of the detail page without it affecting the VisualForce insert?  Because technically, i have duplicates of the feilds as it is right now...one set in the visual force section..the other set just sitting at the bottom of the full detail page

joshbirkjoshbirk

*facepalm* - of course.  Now it all clicks together.  You've got a chicken and egg problem, right?  You want to remove the fields from the layout and have them on the VF form, but you need the user to be able to enter that data for your VF component to operate.

 

So I think now you are back to the edit conundrum.  You could:

 

1) Put input fields into the VF component hand have the user edit on the view page.  That would require updating the null block we have above with a form similar to the Book example I tested out.

 

2) Override the edit page completely, and include the inputFields for the Health Plan on the overridden page.  This obviously has the normal issues of not being able to rely on the Page Layout Editor for field control, etc.

 

I suppose a third would be to have a page just for editing the Health Plan, and add a button to that page on the layout.  A bit of both approaches there.

sdevelopersdeveloper

As I currently have it,  the entire Edit page is redone as a visual force page.  But when I try to remove the fields from the Account Page Layout, it wont show up in my Edit Visual Force page.  It's not like they get deleted out of the code, they just simply won't show up at all. Then it also, won't show up in the VisualForce insert on the main display page.  

 

It's as if when I remove them from the page layout, it overrides all of my code.