function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Zachery Tapp 10Zachery Tapp 10 

Opportunity Contact Role Clone Trigger

Apex noob here. I'm trying to clone an Opportunity and all Contact Roles on any insert or update on a closed won opportunity greater than $500. So, if the opportunity or contact roles are updated, added or deleted, I'd like the clone to inherit those new or updated roles. Is this even possible? I know you can't actually run a trigger on the OpportunityContactRole object - which would be the easiest - but I was wondering if I could effectively look for changes in that related list from the Opportunity object trigger and then run the clone logic there.

One thought I had was rather than trying to do it this way was to essentially add a button/checkbox to the opportunity and instruct users to check the box on the records they wanted cloned as this will be for prospecting in the next FY.

My question is - is that first one even possible? Is it possible to compare the related list size or look for changes in any efficient way. Like would I effectively have to loop through the contact roles before the insert/update and after the insert/update and compare all the fields on the contact role?
Best Answer chosen by Zachery Tapp 10
William LópezWilliam López
Hello,

This idea has been around for some time and I think you will have to come with a workaround.

Please check this it might help you.

http://salesforce.stackexchange.com/questions/47190/trigger-to-find-change-in-contact-role-for-an-opportunity

Regards,

Bill

All Answers

William LópezWilliam López
Hello,

This idea has been around for some time and I think you will have to come with a workaround.

Please check this it might help you.

http://salesforce.stackexchange.com/questions/47190/trigger-to-find-change-in-contact-role-for-an-opportunity

Regards,

Bill
This was selected as the best answer
Zachery Tapp 10Zachery Tapp 10
Woof. Okay. In my initial research, I learned that I didn't have access to that Contact Role from the trigger. I'll look into these workarounds and upvote that idea - thank you!