Find your content:

Search form

You are here

PageLayouts and Fieldsets in APEX


We've repeatedly tried to figure out ways to display a Pagelayout and/or FieldSet settings in our custom VF pages without having to rely on the standard controller.

For example to display a fieldset rightnow we use a VF loop:

<apex:repeat value="{!$ObjectType.Project_Task__c.FieldSets.Project_Task_Field_Set}" var="f">
   <apex:outputField value="{!currentTask[f]}" rendered="{!NOT(editMode)}"/>
   <apex:inputField value="{!currentTask[f]}" styleclass="{!f}" required="{!f.Required}" rendered="{!editMode}"/>

The issue being that if we can't query the fields that are currently part of the installed org's preferences, than we can't save them to the record without using the standard controller which abstracts this out.

Also, we can't use an <apex:details /> tag because it automatically redirects to another page when using its standard buttons and we're working inside of a page that we don't want to redirect after saving.

Is there anyway in APEX to discover the users current fieldset for a custom sObject?

Attribution to: jordan.baucke

Possible Suggestion/Solution #1

Have you looked at Schema.FieldSet? It looks like it would do the trick for you. The MerchandiseDetails example at the end of the page uses the Field Set without the standard controller.

Attribution to: Peter Knolle
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content