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 ContactManipulation on Account (after insert,after update ){ Map<Id,Account> accMap=new Map<Id,Account>(); List<Contact> conListoInsertUpdate=new List<Contact>(); if(Trigger.isInsert){ for(Account acc :Trigger.new){ Contact con=new contact(); con.LastName=acc.Name; //Add if any additional fields need to map from Account conListoInsertUpdate.add(con); } }if(Trigger.isUpdate){ for(Account acc :Trigger.new){ accMap.put(acc.Id,acc); } for(Contact con : [SELECT Id,LastName,AccountId FROM Contact WHERE AccountId IN : accMap.keySet() ]){ con.lastName=accMap.get(con.AccountId).Name; conListoInsertUpdate.add(con); } } try{ upsert conListoInsertUpdate; }catch(DmlException de ){ System.debug(de); } }
Try with below code it will help ! Thanks
Manoj