You need to sign in to do that
Don't have an account?
Gail
Map of Opp ID and Contact Owner ID from Opp ID
I need to create a map of the Opp ID and the primary contact owner id when I have the opp id.
So far, I have:
for (OpportunityContactRole OCR: [Select ContactId from OpportunityContactRole where OpportunityID in :newOpp and IsPrimary = TRUE]){
OppAndContact.put(OCR.id, OCR.contactId);
}
I'm kind of stuck now - is there a way I can get the map in one step?
So far, I have:
for (OpportunityContactRole OCR: [Select ContactId from OpportunityContactRole where OpportunityID in :newOpp and IsPrimary = TRUE]){
OppAndContact.put(OCR.id, OCR.contactId);
}
I'm kind of stuck now - is there a way I can get the map in one step?
Or
All Answers
Or
for (OpportunityContactRole OCR: [Select Opportunityid, ContactId, Contact.OwnerId from OpportunityContactRole where OpportunityID in :OppIds and IsPrimary = TRUE and Contact.Owner.UserRole.Name like '%SDR%']){
//add Opp ID and Owner name to a Map of opp id and contact name string
OppAndContactOwner.put(OCR.Opportunityid, OCR.Contact.OwnerId);
}
Needed to put in the Opp Id, not the OCR ID and didn't realize at first I could traversed down to Contact Owner ID.