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
Inna KersmanInna Kersman 

Apex code help please - what does it mean?

Hi,

Could someone please explain to me in plain English what the attached piece of code does? I'm trying to identify what's triggering the Collision detection error and if it's safe to deactivate this trigger (screenshot attached).


Thanks in advance.User-added image


 
Andrew GAndrew G
Hi Inna

If you have not placed the /* and */ at start and end, then the trigger does nothing.  If that was you testing, then:

For any opportunity that triggers the code, 
If there is a primary contact, check in the OpportunityContactRoles for that primary contact already having a OCR of "Key Sales Contact".
If no such OCR exists, create one for the primary contact and associate it with the opportunity.
If there is an invoicing contact, check in the OpportunityContactRoles for that invoicing contact already having a OCR of "Invoicing Contact".
If no such OCR exists, create one for the invoicing contact and associate it with the opportunity.

HTH

Regards
Andrew
Inna KersmanInna Kersman
Thanks Andrew. This helps a lot.