7

I am building a managed package that includes a VisualForce page that overrides the Account Edit page (by overriding the Edit button). Will users be able to customize this page? I worry that if they add fields to the Account layout, they will have no way to edit those fields, since my edit page overrides the one that would be generated based on the Account layout.

8

No, users can't modify managed code, including Visualforce pages. Instead, you should offer your functionality as a component, and an unmanaged page template for the administrators to modify at their leisure. The default template might look like this:

<apex:page standardController="Account" extensions="namespace.MyExtension">
   <!-- put your code here -->
   <namespace:myComponent accountId="{!Account.Id}" />
   <!-- you can put more code here -->
</apex:page>

Alternatively, consider using the REST API to render the account layout directly from metadata, or use some template system where users specify the field order, etc.

  • How can I include an unmanaged page template in a managed package? – Neo May 14 '15 at 17:03
  • Also, can you point me in the right direction regarding rendering the Account layout from metadata? – Neo May 14 '15 at 21:50
4

No, they will not be able to edit the page.

The cleanest solution for this problem would be to generate the fields displayed dynamically based on field sets.

Here is an excellent article on using field sets to create VF dynamically. You would probably need to create multiple field sets for different sections of the page etc.

Here is a sample of what your code would look like:

    <apex:page standardController="Account">
  <apex:form >
      <apex:pageblock >    
          <apex:pageBlockSection title="Account detail">
             <apex:repeat value="{!$ObjectType.Account.fieldsets.accountFieldSet}" var="fieldValue">
                 <apex:Inputfield value="{!Account[fieldValue]}"/>
             </apex:repeat>
          </apex:pageBlockSection>
      </apex:pageblock>
    </apex:form>
</apex:page>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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