Activity Forums Salesforce® Discussions How can I get all the Fields of an sObject in Salesforce apex class without hardcoding? Reply To: How can I get all the Fields of an sObject in Salesforce apex class without hardcoding?

  • saloni gupta

    Member
    August 14, 2017 at 1:34 pm

    Hi Mohit,

    You can try this :-

    string fields = '';

    Map<String,Schema.SObjectField> fieldMap = Schema.SObjectType.Opportunity.fields.getMap();

    for(String field : fieldMap.keySet())

    {

    fields += field + ', ';
    }
    System.debug('fiedsOpportunity=='+fields);