Is there any way to mark the field required by default in the fieldset?

enter image description here

i want that the required checkbox become non editable.



I don't believe this can be made non-editable. If you always want this field to be required, you would have to make this field required on Object level (by checking required as true while creating this field). Then, you need to make sure that this field is only used in fieldSets and not in any where else. If you decide to use this somewhere else you will have to provide some value into the field (which may or may not be your business logic).

Coming to the programming part, we also have these two attributes in FieldSets:

  1. DBRequired - Indicates whether the field is required for the object.
  2. Required - Indicates whether the field is required in the field set.

You can easily reference these variables in your VF page like this:

<apex:repeat value="{!fields}" var="f"> <apex:inputField value="{!merch[f.fieldPath]}" required = "{!OR(f.required, f.dbrequired)}"/> </apex:repeat>

where "fields" is the list of fields of fieldSets returned by the controller.

A field in a field set can be required by either the field set definition, or the field’s own definition.

FieldSetItem represents an individual field in a field set."isRequired" field is a read only field so we also cannot modify it using apex code.

| improve this answer | |
  • Thanks Rajeev for this details, but let me tell your the actual story i just written this post because i'm getting mentioned checkbox as none editable hence i thought, should ask people to achieve this behavior which resolve my problem. Please let me know if you have any pointer. – Dildar Hussain May 15 '15 at 5:56
  • Let me check once – the_phantom May 15 '15 at 5:58
  • There must be some issue with user permissions. I checked but I could not replicate the same. I always find this checkbox editable. – the_phantom May 15 '15 at 6:58
  • We also raised a SF ticket and they replied that there is some setting in the manifest/meta data file. – Dildar Hussain May 15 '15 at 9:21
  • How do we change that? – the_phantom May 15 '15 at 9:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.