2 réponses
Hi Narendra,I don't think you need custom setting here. You can dynamically get the field API names using $ObjectType.The $ObjectType global variable provides access to a variety of schema information about the objects in your organization. Use it to reference names, labels, and data types of fields on an object, for example.$ObjectType is a “deep” global variable, and offers the opportunity to use it in a “double dynamic” reference, like so: $ObjectType[sObjectName].fields[fieldName].Type
Eg: This Retrieves all the API names for Product Object.
List<Schema.SObjectType> objects = new List<Schema.SObjectType>{ Product2.SObjectType};
for(Schema.SObjectType objType: objects){
for(Schema.SObjectField fld: objType.getDescribe().fields.getMap().values()){
System.debug('API Field Name = '+fld.getDescribe().getName());
}
}
Reference :
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_dynamic_vf_globals_objecttype.htmRegards,Avishek