16

Well, you've probably figured out by now that Triggers aren't supported on OpportunityContactRole (OCR). And, when an OCR is CRUD'd, there is no trigger that fires on the Opportunity either. There is an idea for this - https://success.salesforce.com/ideaview?id=08730000000BrdvAAC I've seen three workarounds Run a scheduled batch apex job that sweeps the ...


12

Flow Get Records cannot perform a single query using a collection of IDs -- you have to loop through the collection and get each record individually. If governor limits are an issue in your use case, you'll have to do this in Apex instead. You can also vote on this Idea.


4

I don't think there's much you can do here, as per the usual with Opportunity Contact Role. Since there's no triggers or validation rules on that object, you don't have any real-time chance to intervene in the transaction. You're stuck then with either (a) Scheduled Apex to locate and remedy those records; or (b) observing in real time with Change Data ...


3

The OpportunityContactRole SObject has all sorts of limitations You can not add custom fields to it (as of V31) You can not write triggers against it (as of V31) You can, however, add/remove Contact Roles Your alternative would be to create a new custom junction object between Contact and Opportunity and manage as any other custom junction object - ...


3

Contact Roles is indeed the prescribed solution. You cannot make it mandatory upon opportunity creation, unless you create a Visualforce page for creating new opportunities. You could block the opportunity from moving to a next stage unless Contacts ar linked to the Opportunity. For this you'd need a trigger on Contact Roles that updates a field on ...


3

You should check out techtrekker's custom event handler functionality for Account and Opportunity contact role objects using Visualforce pages. The recording of his DF talks is here: http://youtu.be/7QAWIPw5VIk The Github repo is here: https://github.com/techtrekker/DF13-VF I've not tried it, but I found it to be a particularly innovative solution.


3

You can try something like this. Select Id,Name,(select Id,ContactId,Contact.Name from OpportunityContactRoles) from Opportunity


3

You should be able to iterate the list and add the field to a separate collection: List<String> referralIds = new List<String>(); for (OpportunityContactRole ocr : [/*query*/]) referralIds.add(ocr.Contact.Referral_Id__c);


3

There's only one primary contact... But they have multiple roles. Salesforce allows this, so you must account for this. Keep in mind that any role record with primary on an opportunity will have the same contact as all primary roles for the opportunity. While the UI implies that only one record can be made primary, you can cause this to happen by selecting ...


3

You should be able to add a Left Inner Join in addition to your Left Anti Join: SELECT Id FROM Contact WHERE RecordType.DeveloperName = 'Customer' AND Id NOT IN ( SELECT ContactId FROM OpportunityContactRole WHERE Opportunity.CreatedDate > 2017-09-03 ) // below clause ensures there is at least one related Opportunity AND Id IN ( SELECT ...


2

Your gut feeling is correct. You can't restrict Contact Roles by the use of triggers. Keep in mind that a custom object will use 2kb of data storage per record, instead of the free cost that contact roles offer. Other than that drawback, this solution would work as you intend. Contact roles have no "additional" functionality that you'd have to consider.


2

Here's some modifications to your trigger that should point you in the right direction. Basically you want to use maps to do what you attempting. Your code was a bit unclear around your delete method. You don't want to do that inside your for loop one record at a time. Collect them all and do it all in a single operation. If you want to do error handling, ...


2

This is not possible with standard functionality. The Contact Role page type of functionality is not exposed for custom relationships. There is now way to see how it is done (e.g., see code, etc.) You will have to create a visualforce page to do what you want to do.


2

Something that is now possible with Summer '19 is to use Change Data Capture events in conjunction with an Apex trigger on OpportunityContactRoleChangeEvent to monitor for changes. There are some details on this in Triggers on Opportunity/Account Contact Role objects – Using Change Data Capture by Narender Singh.


2

This is a bit of a pain as you can't use a roll up summary field or write a trigger on the OpportunityContactRole object. This is a free, unmanaged, Appexchange product that does this: https://appexchange.salesforce.com/listingDetail?listingId=a0N300000025Vs1EAE Note the most helpful negative review: https://appexchange.salesforce.com/listingDetail?...


2

opportunityContactRole is a junction object between Opportunity and Contact. It can only be customized through the picklist for Role You view the OCR through either a related list on the Opportunity page layout and/or the Contact page layout. If not appearing, then customize the page layout to add it.


2

One solution that I will suggest is to use the batch apex for this. The batch would take all the OpportunityContactRole records from the system, check who is the primary contact and based on that, update the opportunity object field. You may also compare the values you have stored on the opportunity object record and pick only those who are changed. Hope ...


2

Hi Matt this is possible. You can query opportunity Contact Role and have a scheduled batch to perform intended operations on newly created opportunityContactRole. Make sure you apply proper filter like using CreatedDate > :LAST_RUN or CreatedDate = TODAY [Considering you are processing all records.]


2

I'd like to post this as a comment, but I think it became too big for it. I think that your real question might be Why can't I see some fields (Referral_ID__c) with system.debug(...). The reason why you don't see Referral_ID__c in your logs it's because your query is getting this field from a parent relationship (Right Outer Join). If you directly debug ...


2

It seems that the code snippet you provieded is correct. I just copy-pasted it to my dev org and it works perfectly - the first contact is populated as primary. It's either I do your business process incorrectly or the problem isn't in that trigger. I would suggest you to test this trigger on a clean dev org and check if the first contact is not populated as ...


2

Go to Setup quick search "User Interface" Un-check the "Show Quick Create" checkbox.


2

I might try a different data model Party__c - Represents an entity that is on one side of the transaction. Could be a person, a trust, an LLC, etc. You could model Party in the Account object or use a custom object. Transaction__c - Represents a real estate transaction (date, time, reference to a Property__c, asking Price, selling price). ...


2

Yes, you can use the OpportunityContactRoles relationship: <messaging:emailTemplate subject="Test" recipientType="Contact" relatedToType="Opportunity"> <messaging:plainTextEmailBody > <apex:repeat value="{!recipient.OpportunityContactRoles}" var="contactRole"> You are related to the following opportunities: <apex:outputText rendered=...


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 ...


2

You're not querying the OpportunityContactRoles in your SELECT clause. Map<Id, Opportunity> relatedOppMap = new Map<Id, Opportunity>( [Select Id, Name From Opportunity Where Id IN (Select OpportunityId From OpportunityContactRole Where ContactId =: contIdsMap.keySet())] ); Your ...


2

This is quite doable (in Lightning only). When editing the OCR page layout, you have to edit the Multi-Line Layout, not the layout for the OCR detail page. This is covered in a Knowledge Article


1

//Handler public with sharing class CreateNewTaskOnOpportunityHandler { public void onAfterInsert(List<Task> lstTask){ Set<Id> contactId = new Set<Id>(); for(Task t : lstTask){ contactId.add(t.WhoId); System.debug('>>>>>>Ids: '+t.WhoId); } List<Contact> lstContact = [Select Id,LastName,(Select ...


1

It's not a tab object, it's seen by salesforce as more of a subservient, opportunity-specific object, so no separate tab was deemed necessary. What purpose are you trying to fill? Could a report solve your issue?


1

You can not assign contact role to opportunity when opportunity does not exist. So you first have to create opportunity then you can assign contact role to it. While your trigger may work on update event. In addition to this If you prefer to use custom page to create opportunity with related list then you can achieve this by providing feature to create ...


1

just like Anup and greenstork suggested - it's not best practice to have a soql query inside of a for loop and also since we can't tell for sure if the opportunity records it might be best for you to create a test class and then create an oppotunity as well as an OpportunityContactRole and associate the OpportunityContactRole to the opportunity and run an ...


Only top voted, non community-wiki answers of a minimum length are eligible