How to get all the fields in a Field Set in Salesforce?

Sample Field Set:



Sample Code:


  1. for ( Schema.FieldSetMember f :  SObjectType.Employee__c.FieldSets.Test.getFields() ) {  
  2.   
  3.     system.debug( f.getFieldPath() );  
  4.       
  5. }  

Here Employee__c is a Custom Object and Test is the field set name.

Output:



2 comments:

  1. how to get reference field object Name through fieldset

    ReplyDelete
    Replies
    1. You cannot do that. Check the supported methods from the below link
      https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_Schema_FieldSetMember.htm

      Delete