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
lawlaw 

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 law
Deepak Kumar ShyoranDeepak Kumar Shyoran
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

Deepak Kumar ShyoranDeepak Kumar Shyoran
You can use below code to view another fields on Contact.

public void doAutoSubscribe(Map<Id, Contact> contactMap) {
Set<ID> advisorIDs = contactMap.keySet();   
system.debug(' ADVISOR ID----- >' + advisorIds);    
for(Contact con :   contactMap) {
System.debug(' Contact First Name --'+con.FirstName) ;
System.debug(' Contact Last Name --'+con.FirstName) ;
System.debug(' Contact AccountID --'+con.AccountId) ;
}

}


lawlaw
Deepak

I receive " Compilation error: Loop must iterate over a collection type:"
I believe this is because  con  is not a list, therefore I can't iterate on it.

Lawrence
Deepak Kumar ShyoranDeepak Kumar Shyoran
Opps sorry that's was my fault Try below code

public void doAutoSubscribe(Map<Id, Contact> contactMap) {
Set<ID> advisorIDs = contactMap.keySet();  
system.debug(' ADVISOR ID----- >' + advisorIds);   
for(Contact con :   contactMap.values()) {
System.debug(' Contact First Name --'+con.FirstName) ;
System.debug(' Contact Last Name --'+con.FirstName) ;
System.debug(' Contact AccountID --'+con.AccountId) ;
}

}


lawlaw
Yes,  values does work.   I am able to see the fields in your system.debug.  FirstName.
However I have a field called RecordType(The DataType is "Record Type").  This is showing as Null and I have verified a value is in the field.
 
Is there something special I must do to access a Field with the "Record Type"  Data type?
Deepak Kumar ShyoranDeepak Kumar Shyoran
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