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
chris_parxchris_parx 

Using Field Set with unknown Object at runtime

Hi,

 

I would like to use fieldset in a VF Page but unfortunately, I don't know the name of my Object at the compilation time but first at the runtime.

 

To use a fieldset, it looks normally like this: {!$ObjectType.Account.FieldSets.MyFieldSet} with MyFieldSet the name of the fieldset and Account the object... But in my case, I have to do something generic and I don't know if it's an Account, or a Contact, or anything else. So I would like to be able to do something like {!$ObjectType.get('Account').FieldSets.MyFieldSet} and to remplace the string 'Account' with a variable from my controller.

 

Anyone has an idea?

 

Thank you!

 

Shashikant SharmaShashikant Sharma

Not Possible, you have to provide field set name in the VFP staticll , can not decide it at run time,

I would suggest to think your implementation with dynamic binding without using field set, using map.

If you want to see an example 

http://forceschool.blogspot.com/2011/06/dynamic-binding-when-object-name-is.html

chris_parxchris_parx

thank you for your answer! I was doing now indeed something similar like in your example but fieldsets are much nicer, unfortunately, they are useless in many cases