function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Srinu SomuSrinu Somu 

object field describe is not working for @AuraEnabled method

@AuraEnabled
	public static List<String> getFieldsLst(String selectedObject) {
		Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Map<String, Schema.SObjectField> fieldMap = schemaMap.get(selectedObject).getDescribe().fields.getMap();
        /*Map<String,String> fieldLabelNameMap = new Map<String,String>();
		for(Schema.SObjectField sfield : fieldMap.Values()) {
			schema.describefieldresult dfield = sfield.getDescribe();
			fieldLabelNameMap.put(dfield.getLabel(),dfield.getname());			
		}*/
        List<String> fieldLabelLst = new List<String>{'test1','test2'};
        //fieldLabelLst.addAll(fieldLabelNameMap.keyset());
		return fieldLabelLst;
	}
Due to the line '
Map<String, Schema.SObjectField> fieldMap = schemaMap.get(selectedObject).getDescribe().fields.getMap();' my method is returning null.
Please help me out.

Thanks.
Srinu SomuSrinu Somu
Note: It is working, if I call from developer console, only when I try to fectch from the lightning controller, it is returning null.