Activity Forums Salesforce® Discussions Is there any way to get all the fields of the sObject without using their API names?

  • Ankit

    Member
    March 20, 2018 at 2:14 pm

    Hi Kapil,

    You can follow this link Click.

    Thanks

  • PRANAV

    Member
    March 20, 2018 at 2:27 pm

    Hi Kapil,

    You can use “WORKBENCH” for this. In workbench you have to first login with your salesforce credentials and then go to Queries tab and select SOQL Query. There you have option to select your object and all their fields with filter and sort functionality also.

    Hope this will helps you.

  • Ratnakar

    Member
    March 21, 2018 at 7:00 am

    Hi kapil,

    you can use following code to get fields.

    SObjectType objectType = Schema.getGlobalDescribe().get('objectAPIName');
    Map<String,Schema.SObjectField> mfields = objectType.getDescribe().fields.getMap();

    mfields map have field names for that particular object which you will mention in objectAPIName.

    I hope this help you.

  • Parul

    Member
    September 18, 2018 at 7:52 pm

    I want to add some points:

    public Void GetAllField()
    {
    String query =”;
    String SobjectApiName = ‘Account’;
    Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
    Map<String, Schema.SObjectField> fieldMap = schemaMap.get(SobjectApiName).getDescribe().fields.getMap();

    String strFields = ”;

    for(String fieldName : fieldMap.keyset() )
    {
    if(strFields == null || strFields == ”)
    {
    strFields = fieldName;
    }else{
    strFields = strFields + ‘ , ‘ + fieldName;
    }
    }

    query = ‘select ‘ + strFields + ‘ from ‘ + SobjectApiName + ‘ Limit 10 ‘;

    List <Account> accList = Database.query(query);

    }

     

    Thanks

Log In to reply.

Popular Salesforce Blogs