public class FieldSetExample { /** * This method is responsible to return list of fields (label, api and type) avaliable * under field set of an object passed as parameters. * */ public static List<FieldSetProperties> getFieldFromFieldSet(String objApi, String fieldSetName){ List<FieldSetProperties> lstOfWrapper = new List<FieldSetProperties>(); Schema.SObjectType sObjType = Schema.getGlobalDescribe().get(objApi); Schema.DescribeSObjectResult desSObjRslt = sObjType.getDescribe(); Schema.FieldSet fieldSetIns = desSObjRslt.FieldSets.getMap().get(fieldSetName); for( Schema.FieldSetMember fieldSetMember : fieldSetIns.getFields() ){ FieldSetProperties wrapperIns = new FieldSetProperties(); wrapperIns.label = String.valueOf(fieldSetMember.getLabel()); wrapperIns.fieldName = String.valueOf(fieldSetMember.getFieldPath()); wrapperIns.fieldType = String.valueOf(fieldSetMember.getType()).toLowerCase(); lstOfWrapper.add(wrapperIns); } return lstOfWrapper; } /** * Wrapper class to hold fieds properties like label, field api and field type. * */ public class FieldSetProperties{ public String label; public String fieldName; public String fieldType; } }
Thursday, May 31, 2018
How to fetch Field(s) under Fieldset using Apex.
Data Cloud Part 6: Practical (Ingest Physical Store's Customer details and Sales details)
Hope you have already created your Data Cloud Org and also downloaded the Customer's details and Sales details from previous posts. Now...