+ Start a Discussion

Problem while Fetching list of fields for a custom object

Hi All, I am trying to fetch the list of fields for a custom object.. below is the code

String fieldNames = Field_Details.getFieldDetails('Inspection_Checklist__c');

my object definition is as

Singular Label -- Inspection Checklist
Plural Label -- Inspection Checklist
Object Name -- Inspection_Checklist
API Name -- Inspection_Checklist__c

I tried passing all possible values but it not returning anything. same code iis working for another Custom Object... Am i missing any thing.. please help

Hi rajufu,
     Can you post the code of getFieldDetails? That will help to solve this problem.
praveen murugesanpraveen murugesan
Hi Raja,

You can try this way. 

        String fieldValues = '';
        SObjectType objectType = Schema.getGlobalDescribe().get(Inspection_Checklist__c);
        DescribeSObjectResult objDesc = objectType.getDescribe();
        Map<String, SObjectField> fields = objDesc.fields.getMap();
        Set<String> fieldSet = fields.keySet();
        for(String f : fieldSet)
            fieldValues += f +',';
        fieldValues= fieldValues.substring(0,fieldValues.length()-1);
        return fieldValues;

Mark this as solution if you got the answer.


Praveen Murugesan