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
Lukesh KarmoreLukesh Karmore 

Unknown property 'String.Required getting error

whenever i set required="{!a.Required}" i am getting above error why it is

<apex:pageBlockSection  >
<apex:repeat value="{!fieldList}" var="a">
    <apex:inputField value="{!actObj[a]}"  required="{!a.Required}"/>
</apex:repeat>
</apex:pageBlockSection>
ANUTEJANUTEJ (Salesforce Developers) 
Hi Lukesh,

>> https://www.reddit.com/r/salesforce/comments/b2vtgx/conditional_required_field/

>> https://salesforce.stackexchange.com/questions/161604/rerendering-conditionally-required-fields-in-vf-how-to-make-field-unrequired

You can check the above two links that have implementations of how to make the field required conditionally,

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.
SwethaSwetha (Salesforce Developers) 
HI Lukesh,
Required permits only boolean values- true or false. I see in this case you are passing a string that is not valid and hence the error.

You could try something like below
Email: <apex:inputField value="{!Book__c.My_Email__c}" required="{!IF(CONTAINS(Book__c.Country__c,"USA"),"true","false")}"/>

<apex:inputField value="{!Case.field2__c}" rendered="{!Case.Picklist__c=='Option 2'}" required="{!Case.Picklist__c=='Option 2'}"/>

If this information helps, please mark the answer as best.Thank you
Lukesh KarmoreLukesh Karmore
 Hello Swetha,
But syntax is correct  as per document look below
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_fieldsets_describe.htm
SwethaSwetha (Salesforce Developers) 
HI Lukesh,
I checked the documentation and the syntax has an OR() which returns a boolean value too.

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

OR() Determines if expressions are true or false. Returns TRUE if any expression is true. Returns FALSE if all expressions are false.

Formula Field Example:
IF(OR(ISPICKVAL(Priority, "High"), ISPICKVAL(Status, "New")), ROUND(NOW()-CreatedDate, 0), null)

This formula returns the number of days a case has been open if the Status is new or the Priority is high. If the case was opened today, this field displays a zero.

Reference: https://help.salesforce.com/articleView?id=sf.customize_functions_i_z.htm&type=5#OR

If this information helps, please mark the answer as best.Thank you