0

I have a Vf page where I am displaying all the objects from the current environment. I am displaying it in a selectList. I need to get all the field set which are there on the object which is been selected dynamically. Is it possible to get it there on Vf page. Please help me out to get the solution over this issue.

  • Here I ma able to get all the fields set related to the object I select but not able to get the label of the field set. – Anu Sep 9 '14 at 8:58
  • Can you post the code you've written so far? – Davin Casey Sep 9 '14 at 9:45
  • i want to check you code, then sure i will help you. – Riaz Muhammad Mar 5 '15 at 12:27
2

You can display a list on page which holds the names of the field sets when sobject is selected dynamically on page.

List<String> listOfFieldSetApiNames = new List<String>();
String strObjectApiName = 'Account';
Schema.SObjectType sObjType = Schema.getGlobalDescribe().get(strObjectApiName);
if( sObjType != NULL ) {
    Map<String, Schema.FieldSet> fieldSetNameToItsRecord = sObjType.getDescribe().fieldsets.getMap();
    listOfFieldSetApiNames.addAll( fieldSetNameToItsRecord.keySet() );
}

"strObjectApiName" this instance will be referred on page to hold the valid sobject api name and "listOfFieldSetApiNames" this will display the respective field sets.

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.