+ Start a Discussion
Brianna BollettieriBrianna Bollettieri 

Duplicate Opportunity Email Notification and Approval

Hi! So I am working on creating an email notification for duplicate opportunities, however I'm not sure how to go about doing so. This is how I want it to work:

1. Duplicate opportunities are identified based on the opportunity name and BU
2. An email is then sent the managers of each opportunity owner notifying them this has occurred
3. If possible, locking both opportunities for approval
4. Then once approved the record is unlocked, if rejected it remains locked

So I know that duplicate rules and matching can't be done for opportunities. But I figured I would see if anyone knew of a workaround for this. Any input would be greatly appreciated!
GauravGargGauravGarg

Hi Brianna,

For this approach you need to write custom code.
1. Custom code will check if there is any other Oportunity exist having same name and BU combination.
2. If found, then we will trigger Approval Process on both the Opportunity.
3. Once the Approval is fire, Email will be sent to both the owner and both the opportunity will be locked and remain locked until approval/rejections. 

Below is link to fire approval process via apex:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_process_example.htm

Hope this will helps you, let me know if you need more insight on this or you can contact me on below details.

Thanks,

Gaurav
Email: gauravgarg.nmims@gmail.com

Brianna BollettieriBrianna Bollettieri
Hi Gaurav,
 
I really appreciate your response. I just need some help with writing the custom code for the first portion of it which is the custom code to check if there are any other opportunities that exist within the system that have the same / similar name and BU combination.
 
Thanks!
GauravGargGauravGarg
sure Brianna, I will help you on this. 
GauravGargGauravGarg

Hi Brianna,

Can you please provide input for below two points:
1. What is the type of BU field, also if possible can you provide me some sample of it.
2. How much opportunity do we have in total. Count of opportunities.

Thanks,

Gaurav