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
WEN JIEWEN JIE 

Can't display field set on Visualforce page.

Hi,

 

I create a field set on Account object, and add Account Name, Account Number and Account Description under the "In the Field Set".

 

Then I use the following code to display them on Visualforce.

<apex:page showHeader="false" standardStylesheets="false" sidebar="false" standardController="Account">

  This is your new Page: TestFieldSetPage
  
  <apex:repeat value="{!$ObjectType.Account.FieldSets.POC_Field_Set}" var="f"> 
        <apex:outputText value="{!Account[f]}" /><br/>
  </apex:repeat>
</apex:page>

"POC_Field_Set" is my field set api name.

But I can't see any data on my Visualforce after I save these code.

 

I follow the "Visualforce Developer's Guide" --- Working with Field Sets

 

So, do I miss some import thing about the Field set?

 

Thanks!

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
bvramkumarbvramkumar

There is no problem with the code.

 

Did you supply an account Id in the URL while testing? because you are using standardController.

 

If it still does not work, check if your profile has access to the Account object and the fileds you place in the fieldset.

 

Also, it would be be best to use apex:outputField rather than apex:outputText while binding any sObject fields.

All Answers

bvramkumarbvramkumar

There is no problem with the code.

 

Did you supply an account Id in the URL while testing? because you are using standardController.

 

If it still does not work, check if your profile has access to the Account object and the fileds you place in the fieldset.

 

Also, it would be be best to use apex:outputField rather than apex:outputText while binding any sObject fields.

This was selected as the best answer
WEN JIEWEN JIE

Hi bvramkumar,

 

Thanks for you answer!

 

I add an account id with my url then I can saw the data.

 

"https://myinstance.visual.force.com/apex/TestFieldSetPage?id=xxxxxxxxxxxxx"

 

Thank you!

Nazeer AhamedNazeer Ahamed

How can we make some selected field in the fieldset is mandatory in VF page.

The fields mentioned as required in field set is not displaying as mandatory field in VF page.

 

Any Idea?