I'm facing the exact same issue described here Error: Incorrect parameter type for subscript. Expected Text, received SetValue

I'm trying to populate a table with a list of input fields, where the actual fields are determined at run time, using dynamic vf binding.

I have the following code in my controller extension

public Lead lead {get;set;}
public Set<String> fieldsToPopulate {get; set;}

Then in my page, I'm looping through the set, which contains the API name of some fields in the Lead object

 <apex:repeat value="{!fieldsToPopulate}" var="f">
     <apex:inputField value="{!Lead[f]}"/>

The above results in the following error when saving the page

Incorrect parameter type for subscript. Expected Text, received SetValue

If I simply print the field name, instead of using an inputField, the field name is displayed correctly.

This follow the pattern described in the official visualforce guide, right here: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_dynamic_vf_sample_standard.htm?search_text=dynamic

Any ideas why this isn't working?

1 Answer 1


Figured it out, the list of field api names must be a list, it cannot be a set, so I changed

public Set<String> fieldsToPopulate {get; set;}


public List<String> fieldsToPopulate {get; set;}

And it resolved the issue.

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.