You need to sign in to do that
Don't have an account?
@ M Coder
Help required for Trigger using trigger-framework
Hello Folks ,
Thanks in Adv .
Can anyone help me to modify the trigger using this frame work please . i didnt understand this so want to see it in an example how to implement. please copy paste the below URL to see the framework .
framework: https://github.com/kevinohara80/sfdc-trigger-framework
can you please modify below trigger with above frame work
//to update child records when parent record is updated in Salesforce
trigger ContactUpdate on Account (after update)
{
set<id> acctid = new set<id>();
map<Id, Account> mapAccount = new map<Id, Account>();
list<Contact> listContact = new list<Contact>();
//adding all id to set<id>
for(Account act :trigger.new)
{
acctid.add(act.id);
mapAccount.put(act.id,act);
}
listContact = [select id ,MailingStreet, MailingCity, AccountId FROM contact where Accountid IN : acctid];
if( listContact.size()>0 )
{
for(Contact con : listContact)
{
con.MailingStreet = mapAccount.get(con.AccountId).BillingStreet;
con.MailingCity = mapAccount.get(con.AccountId).BillingCity;
}
update listContact;
}
}
Thanks in Adv .
Can anyone help me to modify the trigger using this frame work please . i didnt understand this so want to see it in an example how to implement. please copy paste the below URL to see the framework .
framework: https://github.com/kevinohara80/sfdc-trigger-framework
can you please modify below trigger with above frame work
//to update child records when parent record is updated in Salesforce
trigger ContactUpdate on Account (after update)
{
set<id> acctid = new set<id>();
map<Id, Account> mapAccount = new map<Id, Account>();
list<Contact> listContact = new list<Contact>();
//adding all id to set<id>
for(Account act :trigger.new)
{
acctid.add(act.id);
mapAccount.put(act.id,act);
}
listContact = [select id ,MailingStreet, MailingCity, AccountId FROM contact where Accountid IN : acctid];
if( listContact.size()>0 )
{
for(Contact con : listContact)
{
con.MailingStreet = mapAccount.get(con.AccountId).BillingStreet;
con.MailingCity = mapAccount.get(con.AccountId).BillingCity;
}
update listContact;
}
}