Explore Courses Blog Tutorials Interview Questions
0 votes
in Salesforce by (11.9k points)

I need to access the data types of the fields in a object in order to identify each phone, fax, email, and mail field in an object. I've done this from SFDC web services with the DescribeSObject call but the Apex DescribeFieldResult.getType method only returns the display type of the field, not the actual data type.

For example, fields that display a Data Type of Fax like in the image below have a display type of Phone according the getType call. I need something that returns fax for fax fields, mail for mail fields, etc. like the DescribeSObject web service call. Does anyone if that exists in Apex?

Field Information

1 Answer

0 votes
by (32.1k points)

Well, APEX doesn't have that information as of what I know. That said since you can only define custom phone and email fields and not fax and mail/address fields it's possible to write a definitive list of all fax and mail fields. Thus you might consider hard coding which fields are fax/mail fields and dynamically figuring out which fields are phone and email fields use describeFieldResult.getType() calls.

If you wish then you can join Salesforce Apex Training to learn more about creating web services from within the Apex code, SOAP and REST APIs.

Browse Categories