I need to retrieve the compact layout via APEX in order to generate the query. I would like to do something like:
String entity = 'Lead'; String fields = retrieveCompactLayoutFields(entity); String searchQuery = 'SELECT ' + fields + ' FROM ' + entity + ' WHERE Id = :id LIMIT 1';
The compact layout is documented in the Metadata API, but I have no clue in how to access to it. Is it accessible from an APEX class? Can you please share a sample code?