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
rajafurajafu 

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

Thanks
KMForceKMForce
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 +',';
        }  
        if(fieldValues.endsWith(','))
        fieldValues= fieldValues.substring(0,fieldValues.length()-1);
        return fieldValues;

Mark this as solution if you got the answer.

Thanks.

Praveen Murugesan