You need to sign in to do that
Don't have an account?

Dynamically retrieve field values from merge fields
Hi,
I'm using the describeSObject call to retrieve the field names of an object (contact in this case). Once I get the field names, is there a way to dynamically retrieve their values from merge fields? I'm trying to avoid hardcoding the merge fields essentially. Here's what I do:
- Make describeSObject call to retrieve all field values that I'm looking for and store them in a data structure. Let's say I store the field names in an array called fieldNames.
- Merge fields are retrieved by using this syntax: "{!Contact.Phone}". Instead of hardcoding the field name, is there a way to retrieve the value by passing the field name stored in fieldNames?
Or if there is another way to achieve what I'm after, I'd like to hear suggestions.
Thanks in advance.
There are different ways to use the describe call, so I'd recommend you take a look at the Apex docs. To get the field names from the contact object, you could call:
Map<String, Schema.SObjectField> A = Schema.SObjectType.Contact.fields.getMap();
All Answers
Can u give an example how to call the describe object in Apex.
How can we get the Field Names of a particular object(ex.contact)
There are different ways to use the describe call, so I'd recommend you take a look at the Apex docs. To get the field names from the contact object, you could call:
Map<String, Schema.SObjectField> A = Schema.SObjectType.Contact.fields.getMap();