You need to sign in to do that
Don't have an account?

Attempt to de-reference a null object in fieldset
I am trying to get fields from Contact into fieldset. but i am not bale to get the fields properly i am getting error : Attempt to de-reference a null object
my code :
public class DemoCtrl{ public contact DemoCtrl { get; set; } public List<schema.fieldsetmember> getACTFields(){ // System.debug('getField ' + Fields); return getFields('contact', 'ACT'); } public static List<schema.fieldsetmember> getFields(String objectName, String fieldSetName) { Map<String, Schema.SObjectType> GlobalDescribeMap = Schema.getGlobalDescribe(); Schema.SObjectType SObjectTypeObj = GlobalDescribeMap.get(objectName); Schema.DescribeSObjectResult DescribeSObjectResultObj = SObjectTypeObj.getDescribe(); Schema.FieldSet fieldSetObj = DescribeSObjectResultObj.FieldSets.getMap().get(fieldSetName); //DescribeSObjectResultObj.FieldSets.getMap().get(fieldSetName); System.debug('GlobalDescribeMap ' + GlobalDescribeMap); System.debug(' SObjectTypeObj ' + SObjectTypeObj ); System.debug('DescribeSObjectResultObj ' + DescribeSObjectResultObj.FieldSets.getMap().get(fieldSetName)); System.debug('fieldSetObj ' + fieldSetObj ); return fieldSetObj.getFields(); } }
I am getting null into DescribeSObjectResultObj.FieldSets.getMap().get(fieldSetName). Can anybody guide me what is the issue it is not getting filled. Can anybody help me to solve this out.
I would debug to see what value you are passing to your static method in fieldSetName