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


4

I think what you're describing is Opportunity Sales Teams, which is different from Roles. This allows defining a specific group of users as part of the Opportunity Team. The Owner can control what level of access Team Members have. Here is an overview: Opportunity Teams. You just need to Enable Team Selling to get started.


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


2

Roles expand user permissions to access to records beyond what their profile would normally allow. Generally speaking, Salesforce makes security as restrictive as possible using profiles, then uses roles, sharing rules and permission sets to expand access to objects according to the needs of an organization. Profiles and Roles aren't something I can ...


2

I believe DML Requests are not encouraged on page load, hence the future. (The page will load fine, @future just starts an asynch thread of execution) What this code seems to be doing is merely updating a trigger maintained roll up field on Opportunity everytime it is accessed. To be able to make it behave like a trigger, you'd need to create a VF Page to ...


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

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

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

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

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

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

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


1

To rename related lists resulting from a custom relationship (Object Relationships Overview), we will need to locate the custom relationship field on the child object: If the child object is a custom object: From Setup, go to Create > Objects > (Name of Object). If the child object is a standard object: From Setup, go to Customize > (Name of Object) > ...


1

The documentation for renaming related lists can be found here. As you wish to rename a standard object, it looks like this won't give you what you want because if you rename the Opportunity object to something else, then you will still have two Opportunity related lists on the contact page, just with a different name. If there's a valid business reason, ...


1

You need to use before update since you are trying to update same object record. You can directly query and update the opportunity No_Of_Contact__c field trigger fulfillmentcontactcreatedopp on Opportunity (before update) { map<Id, Opportunity> mapOpportunity = trigger.Newmap; // Use aggregate query to get the ...


1

Assuming that public void SF(){ SF2.Opportunity__c = opp.Id; SF2.Rep__c = opp.OwnerId; SF.add(SF2); } is your page action method, you could extend it to: public void SF(){ SF2.Opportunity__c = opp.Id; SF2.Rep__c = opp.OwnerId; Opportunity o = select id (select id, contactId from ...


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