• #26299
     kapil #299
    Forcetalks

    Is there any way to get all the fields of the sObject without using their API names?

    Is there any way to get all the fields of the sObject without using their API names?

    Tagged: , , , , ,

    #26303
    Salesforce | Ankit Ankit #182
    Forcetalks

    Hi Kapil,

    You can follow this link Click.

    Thanks

    #26304
    Salesforce | PRANAV PRANAV #15
    Forcetalks

    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.

    #26311
     Ratnakar #194
    Forcetalks

    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.

    #35111
    Salesforce | Parul Parul #2
    Forcetalks

    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

Viewing 5 posts - 1 through 5 (of 5 total)

Please to reply to this topic.

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2018 Forcetalks. All Right Reserved.

Log in with your credentials

or    

Forgot your details?