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
pooja chauchanpooja chauchan 

Contact Map

In the code snippet below I am able to see the Contact ID in the variable advisorIDS.  What would I add to the code to see another field on the contact record?
Thanks in Advance

public void doAutoSubscribe(Map<Id, Contact> contactMap) {
    
        Set<ID> advisorIDs = contactMap.keySet();
        system.debug(' ADVISOR ID----- >' + advisorIds);       

}
Best Answer chosen by pooja chauchan
Gaurav NirwalGaurav Nirwal

To get the records id you need to try RecordTypeId instead of RecordType, So get recordId from Contact Map and then you can select RecordType > Name by using that Id by firing query on record Type filter by Id

All Answers

Gaurav NirwalGaurav Nirwal

To get the records id you need to try RecordTypeId instead of RecordType, So get recordId from Contact Map and then you can select RecordType > Name by using that Id by firing query on record Type filter by Id
This was selected as the best answer
Wizno @ ConfigeroWizno @ Configero
When you pass in the contactMap variable to doAutoSubscribe, you'll want to make sure that the fields you want to use have been queried. 

Then when you want to get details for a field you can do this:
 
public void doAutoSubscribe(Map<Id, Contact> contactMap) {
    
        Set<ID> advisorIDs = contactMap.keySet();
        system.debug(' ADVISOR ID----- >' + advisorIds);

for(Id contactId : advisorIDs){
  System.debug('First Name: '+ contactMap.get(contactId).FirstName);
  System.debug('Last Name: '+ contactMap.get(contactId).LastName);
  System.debug('My Custom FIeld: '+ contactMap.get(contactId).My_Custom_Field__c); //If this applies
}

}