I have a VF page in which I have an <apex:repeat> tag:

<apex:repeat value="{!seHandoffFields}" var="field">
    <apex:pageBlockSectionItem helpText="{!$ObjectType.DealQualificationSurvey__c.fields[field].inlineHelpText}">
        <apex:outputLabel value="{!field.label}" />
        <apex:outputPanel >
            <apex:inputField value="{!surveyHeader[field]}" rendered="{!surveyHeader.Status__c != 'Completed'}" 
            <apex:outputField value="{!surveyHeader[field]}" rendered="{!surveyHeader.Status__c = 'Completed'}" />

seHandoffFields is a List<Schema.FieldSetmember> for a given field set.

When I have {!field.required} in the code, I get the following error when deploying:

force-app\main\default\pages\DealQualificationSurvey.page Cannot coerce 'core.apexpages.el.adapters.RuntimeTypeMetadataELAdapter@6a6c598f' of class core.apexpages.el.adapters.RuntimeTypeMetadataELAdapter to class java.lang.Boolean (incompatible type)

Here's the kicker, I'm doing the EXACT same thing somewhere else in the Visualforce page and I do not get the error. I only get the error when trying to add it a second time.


It seems that the issue is that I am using field as a variable name in more then 1 repeat tag on the page. Changing the name of field to seField resolved the error.

Note: These tags are not nested. They are not even siblings. They are third cousins at best.

Note 2: This error only happens with some attributes. If I remove the required attribute, the code works perfectly fine (no issues with field.label). I also noticed a different error when trying to use field.fieldPath

Note 3: Api versions tested are 44, 45, and 46.

  • this would have driven me nuts trying to find -- kudos – cropredy May 16 '19 at 17:47
  • You should not use the same variable name more than once in a page, or you risk all kinds of bugs. Sometimes it works okay, other times not. – sfdcfox May 16 '19 at 18:43

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.