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
Faizan Ali 17Faizan Ali 17 

How to query a picklist value and check it against a contact to grab email field?

Hi all,

I would like to know if there is a way to query the database based on the value in the picklist and check it against the name of a contact to grab the email field from that contact?

If there is a way, could someone kindly show an example of this in a class/trigger? The picklist is located on the event/activity object.
ShirishaShirisha (Salesforce Developers) 
Hi Faizan,

Greetings!

If you would like to display or get the Email value from Contact record based on the picklist value then you can query the Contact record(if the picklist field is there on the Contact Object).
 
List<Contact> contacts =[Select Id,PicklistFieldName,Email from Contact where PicklistFieldName='Abc'];

System.debug('Email Address'+contacts.Email);

The above sample code will help you to display the Email address in the debug logs.

Please find the sample code in the below thread:https://developer.salesforce.com/forums/?id=906F00000008r49IAA

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri