What is Opportunity Contact Role In Salesforce and how to fetch contact details from opportunity contact roles


Salesforce is cloud based platform where we configure the salesforce according to our business flow, so before jumping to Opportunity contact role, let consider a scenario where your team is working on the opportunity and your team want to discuss something about opportunity with client, now there can be so many person in company, so to whom should your team talk and who take what decision on the opportunity, as there are so many people in company so whom we should talk in the company regarding the opportunity is definitely a difficult task, so the salesforce provide us way to add contact/person account with roles in the related list of opportunity, this is what we called opportunity contact roles, so if your team know who will take decision on opportunity about quality then it’s better to add that person in contact roles, same we can have so many people which whom you can talk at your client side, so it’s better to add them in contact roles.

How to define contact roles in salesforce

To define contact role for Opportunity, go to  Setup and in left hand search box type contact roles, see below image for more details.
once you click that a screen will be open, where you can define your own role,delete any existing role and reorder them as per your requirements, once you do that then you need to go to any opportunity contact role record and below in the record in related list you will find an option for the contact role, see below pic for more details.
This is how you can define any contact role in opportunity, now you are totally aware why we need contact role and how we can add them in opportunity.
Limitations in contact roles
  • We can’t add any custom fields in contact roles
  • We can’t add any validation rules and trigger on contact roles.

Accessing Contact information from opportunity contact roles via SOQL

There could be a scenario where you probably need to access the contact information from opportunity contact roles, one thing is definitely you needed is the opportunity ID to access the opportunity contact roles, now you want to access the contact information from contact roles, this is possible to do via Apex, see the below SOQL query which you can use in your Apex code.

SELECT Id, Opportunity.Name, Contact.Email, Contact.Name, Role, isPrimary FROM OpportunityContactRole Where OpportunityId =’OpportunityID’

In the above code  OpportunityID is the Opportunity ID from which you want to fetch the contact information of opportunity contact roles, now when you run this query this will give you the email and name information of contact, you can use the same SOQL query to fetch other details of contacts.

Related Articles :

Speak Your Mind



This site uses Akismet to reduce spam. Learn how your comment data is processed.