Tuesday, January 24, 2017

Visualforce - Beyond Basics Series 41 - Dynamic Forms

Issue with Standard Forms in Salesforce ?

In Standard record Edit Page, there's no way we can hide/show a set of Fields for Users to Fill In. This is the big issue when you have hundreds of fields that gets presented to the User.

How to solve with visualforce Page ?

In visualforce page, this problem can be solved by showing/hiding different sections based on the 'certain value' in Fields (or) certain User Action.

Where is the Code ?

<apex:page standardController="Opportunity">
<apex:sectionHeader title="Application - Basic Information"/>
<apex:outputLabel value="Name - "/>
<apex:outputField value="{!Opportunity.Name}"/>
<apex:form>
<!-- Check Box -->
<apex:outputLabel value="Do you want to edit ?"/>
<apex:inputCheckbox value="{!Opportunity.isClosed}">
<apex:actionSupport event="onchange" rerender="EditSection"/>
</apex:inputCheckbox>
<!-- Edit Section -->
<apex:outputPanel id="EditSection">
<apex:outputPanel layout="none" rendered="{!Opportunity.isClosed}">
<apex:sectionHeader title="Edit Section"/>
<apex:pageBlock>
<apex:pageBlockSection>
<apex:inputField value="{!Opportunity.Description}"/>
<apex:inputField value="{!Opportunity.CloseDate}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:outputPanel>
</apex:outputPanel>
</apex:form>
</apex:page>
view raw gistfile1.txt hosted with ❤ by GitHub

Any Screenshots ?



Walk through in a video ?


No comments:

Post a Comment

Thanks for reading my blog !