You need to sign in to do that
Don't have an account?
RP Singh
Create a Formula Field named Domain on Contact Object
1. Create a Formula Field named Domain on Contact Object, This should give me the Domain from Email Field on Contact Object. For Example: - If I save the Contact with Email as testuser@gmail.com, then formula field of Domain should have value “gmail”
2. Add a text Field at Account Level named as Contact Unique Domains
3. Create a trigger on Contact, Which handles Insert / Update / Delete / Undelete scenario. Trigger should get the Account Id from the Contact and then read all the related contacts from that Account and then Store the unique domains to the Account Level. For Example If I have below 3 contacts
Email - testuser1@gmail.com and Domain - gmail
Email - testuser2@yahoo.com and Domain as yahoo
Email - testuser3@gmail.com and Domain as gmail
So there are two unique domain gmail and yahoo, hence my Account text field will be populated with value gmail;yahoo
2. Add a text Field at Account Level named as Contact Unique Domains
3. Create a trigger on Contact, Which handles Insert / Update / Delete / Undelete scenario. Trigger should get the Account Id from the Contact and then read all the related contacts from that Account and then Store the unique domains to the Account Level. For Example If I have below 3 contacts
Email - testuser1@gmail.com and Domain - gmail
Email - testuser2@yahoo.com and Domain as yahoo
Email - testuser3@gmail.com and Domain as gmail
So there are two unique domain gmail and yahoo, hence my Account text field will be populated with value gmail;yahoo
Create a formula field named 'Domain' on the Contact object and use the following formula:
This will extract the domain from the Email field and store it in the Domain field.
Next, write the following trigger on the Contact object:
The trigger queries all the contacts with fields Id, Domain and AccountId whose AccountId matches the triggerd Contact. It then extracts the Domain of each such contact and adds it to a string contactUniqueDomains.
The Account's Contact_Unique_Domains__c field is updated with the contactUniqueDomains value.
(In case, you are triggering multiple contacts at a time, just add a for loop and iterate through each and every Contact triggered instead of using contacts[0] ).
Regards,
Prakhar
All Answers
Create a formula field named 'Domain' on the Contact object and use the following formula:
This will extract the domain from the Email field and store it in the Domain field.
Next, write the following trigger on the Contact object:
The trigger queries all the contacts with fields Id, Domain and AccountId whose AccountId matches the triggerd Contact. It then extracts the Domain of each such contact and adds it to a string contactUniqueDomains.
The Account's Contact_Unique_Domains__c field is updated with the contactUniqueDomains value.
(In case, you are triggering multiple contacts at a time, just add a for loop and iterate through each and every Contact triggered instead of using contacts[0] ).
Regards,
Prakhar
Thanks.