TransWikia.com

how to get all the fields of an selected object(standard and custom) in an org using lightning component

Salesforce Asked by edukondalu on November 20, 2021

i had populate all the object names in the org by using "iteration"in lightning component then i got all object names shown below then my requirement is whenever i onclick any objectname i need to display all fields of that object enter image description here

One Answer

You can get the fields name from the Object name using describe call:

String SobjectApiName = 'Account';
Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Map<String, Schema.SObjectField> fieldMap = schemaMap.get(SobjectApiName).getDescribe().fields.getMap();
for(String fieldName : fieldMap.keyset() )
    {
        system.debug('fieldName -->'+fieldName); // This will give you the api name of the field name.
    }

Answered by Aakriti.G on November 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP