You need to sign in to do that
Don't have an account?
Sonu06
Apex triggerss
Hey guys , I am beginner to salesforce, My requirement is to write the Apex trigger,
-- Suppose I have 1 account Name X and It has 2 contacts, so for the same account X , the email of the Contacts should not be same , if same It should show error. Suppose 1 contact email is abc@g.com and 2 contact email is xyz @g.com , this should be accepted. if both contact has same email address then it should not be accepted.
But if have another account Name Y and it has 2 contact, and if email of 1 of the contact is abc@g.com which is the email of contact of account X then it should be accepted,
So please suggest me the apex trigger for the above requirement.
Note- Please dont share any link for this,, if possible give me explanation with example
Thank you
-- Suppose I have 1 account Name X and It has 2 contacts, so for the same account X , the email of the Contacts should not be same , if same It should show error. Suppose 1 contact email is abc@g.com and 2 contact email is xyz @g.com , this should be accepted. if both contact has same email address then it should not be accepted.
But if have another account Name Y and it has 2 contact, and if email of 1 of the contact is abc@g.com which is the email of contact of account X then it should be accepted,
So please suggest me the apex trigger for the above requirement.
Note- Please dont share any link for this,, if possible give me explanation with example
Thank you
Greetings to you!
I have updated this trigger as you asked using Map. I have created a map of accountId Vs List Of previous contact email. Please mark as Best Answer to help others too.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha.
All Answers
Greetings to you!
I have written a trigger as per your requirement. You can use this code. I have check all others contact that have lookup with the same account and if it have then I match the email and if they have the same email then I added error in that contact.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha.
you can rewrite this code using Map, it will be very helpful me.
Thank you
Greetings to you!
I have updated this trigger as you asked using Map. I have created a map of accountId Vs List Of previous contact email. Please mark as Best Answer to help others too.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha.