You need to sign in to do that
Don't have an account?
SFDC Dummy
How to update field when record created....
Hi All
I have two object Obj1 and Obj2 .both are lookup realtionship.
i have created Obj1 manually..when i am going to create Obj2 ,after creating Obj2 ,some field of Obj1 will be updated in Obj2...
I have two object Obj1 and Obj2 .both are lookup realtionship.
i have created Obj1 manually..when i am going to create Obj2 ,after creating Obj2 ,some field of Obj1 will be updated in Obj2...
u can use this code. i created on Account and Contact fields. if you want to another objets. you can change the fileds and objects.
trigger updateAddressOnContact on Account (after insert, after update) {
map<id,account> accMap=new map<id,account>();
list<contact> clist=new list<contact>();
set<id> accids=new set<id>();
for(Account acc:trigger.new){
accids.add(acc.id);
accMap.put(acc.id, acc);
}
clist=[select id,name, accountid, MailingCity, Mailingstate from contact where accountid=:accids];
list<contact> contactToUpdate=new list<contact>();
for(contact con:clist){
con.MailingCity=accMap.get(con.accountid).billingcity;
con.Mailingstate=accMap.get(con.accountid).billingstate;
contactToUpdate.add(con);
}
if(contactToUpdate.size()>0){
update contactToUpdate;
}
}
Thanks
Thulasi
Try to see following trigger....