0

I used a Query on OpportunityContactRole in Opportunity Trigger.

for(OpportunityContactRole c: [SELECT Id, opportunityid, contactId FROM
         OpportunityContactRole where opportunityid in: newOpp]){

It returns a list when I create and Opportunity from Contact Record Page. But when an Opportunity is created via Lead Conversion this query is Returning Empty List. But after the Lead Conversion, the newly created Opportunity have the Contact Role assigned to it.

Why the OpportunityContactRoles is empty?

TIA

  • Have you checked if the Opportunity Trigger is firing when an Opportunity is being created via Lead Conversion? For triggers to fire on Opportunities and Accounts on Lead Conversion you need to enable "Enforce Validation and Triggers from Lead Convert". – Jigar Shah Jul 31 '18 at 8:09
  • The trigger is working fine. Now as per @sfdcfox, Opportunity Contact Role records don't exist when the opportunity is created during the lead conversion. – Kamal Thakur Jul 31 '18 at 8:35
2

The Opportunity Contact Role records don't exist when the opportunity is created during the lead conversion process (as outlined in this answer). Anything you want to do during the lead conversion process must be done in the Lead After Update trigger, instead. You will probably want to write a utility class and a method so you can call the same logic from two different triggers.

  • Great. To resolve this issue we had to write the code in Lead After Update. worked like charm :) – Kamal Thakur Jul 31 '18 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.