You need to sign in to do that
Don't have an account?
ch ranjith
Not updating the field contact when i insert the field in account
I have contact_update_fiels__c field in account when update or insert record in account the field value should be copied to all related contacts field update_from_account__c its not updating with below code
trigger rt on Account (after insert,after update)
{
set<id> set1=new set<id>();
list<contact> conlistnew=new list<contact>();
for(account acc:trigger.new)
{
set1.add(acc.id);
}
list<contact> conlist=[select id,name,accountid from contact where accountid in:set1];
for(account tempacc:trigger.new)
{
for(contact tempcon:conlist)
{
if(tempacc.id==tempcon.id)
{
tempacc.contact_update_fiels__c=tempcon.update_from_account__c;
conlistnew.add(tempcon);
}
}
}
update conlistnew;
}
trigger rt on Account (after insert,after update)
{
set<id> set1=new set<id>();
list<contact> conlistnew=new list<contact>();
for(account acc:trigger.new)
{
set1.add(acc.id);
}
list<contact> conlist=[select id,name,accountid from contact where accountid in:set1];
for(account tempacc:trigger.new)
{
for(contact tempcon:conlist)
{
if(tempacc.id==tempcon.id)
{
tempacc.contact_update_fiels__c=tempcon.update_from_account__c;
conlistnew.add(tempcon);
}
}
}
update conlistnew;
}
Try it this way:
if(tempacc.id==tempcon.accountid)
All Answers
Try it this way:
if(tempacc.id==tempcon.accountid)
if(tempacc.id==tempcon.id)
Hence, your trigger is not working. Please change it as below:
if(tempacc.id==tempcon.accountid)
If this answers your question, please mark this as the Best Answer for this post, so that others can benefit from this post.
Thanks,
Shashank