Apex Fieldset - getfieldpath in salesforce

use get method to iterate the fieldset value.

public static List<Schema.FieldSetMember> getFields(){
return SObjectType.Account.FieldSets.ExhibitorAuthenticity.getFields();
}

 for(Account itr:exhibitorAuthList){
                for(Schema.FieldSetMember f : getFields()){
                    if(itr.get(f.getFieldPath())=='Apple'){
                        exhibitorAuth.add('Apple');
                    }else if(itr.get(f.getFieldPath())=='Banana'){
                        exhibitorRemaining.add('Banana');
                    } 
                }
            }

    system.debug('API Name ====>' + fieldSetMemberObj.getFieldPath()); //api name
    system.debug('Label ====>' + fieldSetMemberObj.getLabel());
    system.debug('Required ====>' + fieldSetMemberObj.getRequired());
    system.debug('DbRequired ====>' + fieldSetMemberObj.getDbRequired());
    system.debug('Type ====>' + fieldSetMemberObj.getType());

No comments:

Post a Comment