877.703.4488 info@cloudmybiz.com

One of the easiest things in the Salesforce world is updating a page layout. All you have to do is go to the page editor, drag and drop a few fields, and click save. Done! But this, unfortunately, only works for standard Page Layouts. If your business is leveraging Visualforce for any of your pages, you’ve probably learned that updating these layouts can get pretty complicated pretty quickly. Want to move a field to a different section, remove a field you’re not using anymore, or add a new one to the screen? Time to call the developers! Or, with a little creativity and a few Field Sets, you can have a Visualforce page that’s almost as dynamic as a standard page!

Leveraging Field Sets in Visualforce pages is surprisingly simple, and while Apex can supercharge your dynamic Visualforce code, you can use Field Sets without any Apex required. Begin by choosing an object, creating a new Field Set, giving it an easy-to-understand name, drag and drop the fields you want in, and click Save. Now, create a new Visualforce page. In your Visualforce, you’ll “repeat” through the fields in the field set to display those on the screen.

The example below is one of the simplest versions of this, but don’t think this is the end. Once you’ve got the basics working here, you’re ready to get really creative! Now go, sit down with your dev team, and make some awesome, dynamic Visualforce! And don’t forget to tell us about it!

<apex:page standardController="Account" standardStylesheets="true">
<apex:form >
<apex:repeat value="{!$ObjectType.Account.FieldSets.Account_Fields}"  var="f">
<apex:inputField value="{!Account[f]}" /><br/><br/>
<apex:commandButton id="saveBtn" value="Save" action="{!save}" />

-Jared and the Salesforce Guys