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
Richa_LearningRicha_Learning 

Field Sets on VF Page

Hi,
I have create a field sets for Account that has A,B, C,D as fields.  I have 2 record type for Account. A,B is required for 1 record type and C,D is require for another record type. IF i mark them as Require on the fieldset property then all fields are required for both page layout.

How to make sure that they are required on the relevant page layout?
<apex:page standardController="Account" extensions="CloneAccountController">



    <apex:sectionHeader title="Account Edit" />
  <apex:form id="frmId">
        <apex:pageBlock title="Account Edit" mode="edit">

            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
            
            <apex:pageBlockSection title="Account Information"  columns="2" >
            <apex:repeat value="{!$Objecttype.Account.fieldsets.Method}" var="AI">
              
            <apex:inputField value="{!objcase[AI.fieldPath]}" required="{!OR(AI.required, AI.dbrequired)}"/>  
            </apex:repeat>
        </apex:pageBlockSection>
        
        
        
        </apex:pageBlock>
</apex:form>
</apex:page>

 
Best Answer chosen by Richa_Learning
Praveen KHariPraveen KHari
I'm getting rich text as mandatory. check below code and screen shot
 
<apex:page standardController="Account">

    <apex:sectionHeader title="Account Edit" />

  <apex:form id="frmId">
        <apex:pageBlock title="Account Edit" mode="edit">

            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>

            <apex:pageBlockSection title="Account Information" columns="2" >
            <apex:repeat value="{!$Objecttype.Account.fieldsets.MyFieldSet}" var="AI">

            <apex:inputField value="{!Account[AI.fieldPath]}" required="{!OR(AI.required, AI.dbrequired)}"/> 
         </apex:repeat>

        </apex:pageBlockSection>

        </apex:pageBlock>
</apex:form>
</apex:page>

Check the rich text field error msg

All Answers

Praveen KHariPraveen KHari
I recommend to have two field set based on the record type and change your VF code to render correct field set based on record type.

-Praveen K Hari
Richa_LearningRicha_Learning
Ok thanks. I have made Rich text area field as required but that field is not coming as required on the page. any idea?

 
Praveen KHariPraveen KHari
I'm getting rich text as mandatory. check below code and screen shot
 
<apex:page standardController="Account">

    <apex:sectionHeader title="Account Edit" />

  <apex:form id="frmId">
        <apex:pageBlock title="Account Edit" mode="edit">

            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>

            <apex:pageBlockSection title="Account Information" columns="2" >
            <apex:repeat value="{!$Objecttype.Account.fieldsets.MyFieldSet}" var="AI">

            <apex:inputField value="{!Account[AI.fieldPath]}" required="{!OR(AI.required, AI.dbrequired)}"/> 
         </apex:repeat>

        </apex:pageBlockSection>

        </apex:pageBlock>
</apex:form>
</apex:page>

Check the rich text field error msg
This was selected as the best answer
Praveen KHariPraveen KHari
I have changed code at line 17 to <apex:inputField value="{!Account[AI.fieldPath]}" required="{!OR(AI.required, AI.dbrequired)}"/>

 
Richa_LearningRicha_Learning
Thanks so much. I have 1 questions:

1) my requirement is have custom button "NEw" that should have same fields as stanar page layout with some fiels populated. Since i have 2 recor type ( 2page layout), i ceated a 2 VF page from scratc example input field, out put field. do you think this is the best prarctice?
Praveen KHariPraveen KHari
You can do this with one VF page and use "render" keyword based on record type value in VF page.  
Please choose best answer if you think your query got resolved.
 
-Praveen K Hari