function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nitish 73Nitish 73 

Map of field and field response

Hi Everyone, 

I have a requirement where I need to capture the field API Name and the response given to that in a map (in an apex class). 
Like, If on the object record edit page, the Applicant answers 

Country : Canada (Answer is a picklist) 

So, then I need to capture this as a map like

(Country__c, Canada) 


Can you guys guide me on how to achieve this ? 


Thanks
 
Best Answer chosen by Nitish 73
pconpcon
If you use the JSON.serialize method, does that give you the information you need?  Alternately, you could use the Apex field description methods [1] to get a list of all the available field names and iterate through those to build your map.

[1] https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dynamic_describe_objects_understanding.htm