You need to sign in to do that
Don't have an account?
Andrew Keller 30
Apex Trigger to delete duplicate tasks - help?
I am trying to find a way to delete duplicate tasks assigned to contact owners. Our Salesforce is integrated with HubSpot, (though i'm sure this same issue would occur with Pardot) and any time a marketing email is opened by a contact, a task is created for the contact owner notifying them that the email was opened.
Problem is, when spam filters trigger 10-15 opens of the same email for one contact, 10-15 tasks get created for the contact owner.
I'd like to be able to delete a duplicate task with the same subject assigned to the same user on the same day. Salesforce support told me that this would require an Apex Trigger and a developer, but we dont have a devloper in the org. I'm technically our Salesforce Admin, and i'm learning as I go here.
Can anyone point me to some resources that would help with this? Thanks in advance!
Problem is, when spam filters trigger 10-15 opens of the same email for one contact, 10-15 tasks get created for the contact owner.
I'd like to be able to delete a duplicate task with the same subject assigned to the same user on the same day. Salesforce support told me that this would require an Apex Trigger and a developer, but we dont have a devloper in the org. I'm technically our Salesforce Admin, and i'm learning as I go here.
Can anyone point me to some resources that would help with this? Thanks in advance!
If you are new to Code you can try the below Sample code for your requirement,
https://www.mstsolutions.com/technical/preventing-duplicate-records-based-on-multiple-fields-in-salesforce/
For further reference, you can check the below too,
https://developer.salesforce.com/forums/?id=906F000000092IwIAI
https://salesforce.stackexchange.com/questions/208106/how-to-avoid-creating-duplicate-task-when-risk-score-is-changes
I hope you find the above information is helpful. If it does, please mark as Best Answer to help others too.
Thanks.
Hi Andrew,
I would go with a different approach and instead of deleting tasks, I'll block them before they are inserted.
Kindly go through some trigger documentation here : https://trailhead.salesforce.com/en/content/learn/modules/apex_triggers/apex_triggers_intro
Also added a sample trigger that should help you achieve your goal.
Hope this helps.
Regards,
Vishal
You can stop the creation of duplicates tasks with the help of trigger code mentioned below: Please let me know if you face any issues with this. You can also reach out to me directly at:
Gmail: abhibansal2790@gmail.com
Skype: abhishek.bansal2790.
Thanks,
Abhishek Bansal.