function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
trigger ContactNamesOnAccount on Contact (after update, after insert) { Set<id> accIdList = new Set<id>(); for(Contact con : Trigger.new) { accIdList.add(con.accountid); } List<Account> accUpdateList = new List<Account>(); for(Account acc : [Select id, name, Contact_Names__c, (Select Id, name, LastName From Contacts) From Account Where Id In : accIdList]) { List<String> lstSrting = new List<String>(); for(Contact con : acc.contacts) { lstSrting.add(con.lastname); } acc.Contact_Names__c = String.join(lstSrting, ','); } accUpdateList.add(acc); } update accUpdateList; }
Hope it helps you.If the above information is informative please mark it as the best answer.
if you any other assistance please let me know.ThanksVaraprasad
Please find sample code below :
Hope it helps you.
If the above information is informative please mark it as the best answer.
if you any other assistance please let me know.
Thanks
Varaprasad