You need to sign in to do that
Don't have an account?
Schema.DescribeSobjectResult has no member names fieldsets
I pass Opportunity object and opportunity field set.
public static List<Schema.FieldSetMember> readFieldSet(String fieldSetName, String ObjectName)
{
Map<String, Schema.SObjectType> GlobalDescribeMap = Schema.getGlobalDescribe();
Schema.SObjectType SObjectTypeObj = GlobalDescribeMap.get(ObjectName);
Schema.DescribeSObjectResult DescribeSObjectResultObj = SObjectTypeObj.getDescribe();
//system.debug('====>' + DescribeSObjectResultObj.FieldSets.getMap().get(fieldSetName));
Schema.FieldSet fieldSetObj = DescribeSObjectResultObj.FieldSets.getMap().get(fieldSetName);
//List<Schema.FieldSetMember> fieldSetMemberList = fieldSetObj.getFields();
//system.debug('fieldSetMemberList ====>' + fieldSetMemberList);
return fieldSetObj.getFields();
}
Code is perfectly fine. Create field sets in the corresponding object and try passing appropriate field sets name.
Thanks
Hi,
Thanks for your help.
Hi Sureka,
Can you provide a sample code to elaborate and explain the below comment?
Thanks
I tried your code and its working fine. I passed the following variables - readFieldSet('SampleFieldSet1', 'Opportunity'');
SampleFieldSet1 is the name of the field set in my opportunity object.
public static List<Schema.FieldSetMember> readFieldSet(String fieldSetName, String ObjectName)
{
Map<String, Schema.SObjectType> GlobalDescribeMap = Schema.getGlobalDescribe();
Schema.SObjectType SObjectTypeObj = GlobalDescribeMap.get(ObjectName);
Schema.DescribeSObjectResult DescribeSObjectResultObj = SObjectTypeObj.getDescribe();
system.debug('====>' + DescribeSObjectResultObj.FieldSets.getMap().get(fieldSetName)); - This statement is correctly printing the field set variable.
}
Thanks