#Sales Cloud #Service Cloud #Marketing Cloud #Analytics #Nonprofit #Trailhead #Automation #New Releases #Integration #AppExchange
#Sales Cloud #Service Cloud #Marketing Cloud #Analytics #Nonprofit #Trailhead #Automation #New Releases #Integration #AppExchange
#Sales Cloud #Service Cloud #Marketing Cloud #Analytics #Nonprofit #Trailhead #Automation #New Releases #Integration #AppExchange
I need a trigger that pulls all the unique values from Email Domain (custom field) and populates the field Domain Mapping (managed package custom field) separated by a single space and only unique values. Example: Account XYZ has three contacts. Contact 1 has a Email Domain of XYZ.com Contact 2 has an Email Domain of ABC.com Contact 3 has an Email Domain of XYZ.com Accounts Domain Mapping field should be “XYZ.com ABC.com” Object - Field - API Name Account - Domain Mapping - Zendesk__Domain_Mapping__c Contact - Email Domain - Email_Domain__c
i work on as trigger but here has one proble-- i want to update field as Account id related divide field Domain data and updated Account unique field-
Contact field Name- Domain__c
Account Field name--
Trigger--
create trigger---- aftertrigger- call handler class
Handler class--
public class AddDomainHandler {
public static void addDomain(List<Contact> contactsList){
String contactUniqueDomains = '';
List<String> listOfContactUniqueDomains = new List<String>();
Set<id> accIdList = new Set<id>();
for (Contact con : contactsList) {
accIdList.add(con.accountid);
}
List<Account> accUpdateList = new List<Account>();
List<String> DomainList=new List<String>();
for(Account acc : [Select id, Contact_Unique_Domains__c, (Select Domain__c From Contacts)
From Account Where Id In : accIdList]){
for(Contact con : acc.contacts){
if(!listOfContactUniqueDomains.contains(con.Domain__c)){
/* add name to list */
contactUniqueDomains += con.Domain__c + ' , ';
// DomainList.add(con.Domain__c);
}
listOfContactUniqueDomains.add(con.Domain__c);
}
contactUniqueDomains = contactUniqueDomains.removeEnd(' , ');
acc.Contact_Unique_Domains__c = contactUniqueDomains;
accUpdateList.add(acc);
/* clear list to add new account contact names */
// DomainList.clear();
}
update accUpdateList;
}
}
If i want too get multiple contact record which is relate to different account then how to solved -means this list is divide by different account id and updated Unique domain.
Please help me to solved this.