You need to sign in to do that
Don't have an account?

Contact Trigger updating Mailingaddress base on Account BillingAddress
How can i Update Mailingaddress in contact base on Account BillingAddress? and if i put null on account Name in Contact the Mailing Address should be null too
Thanks for Help!
AJ
Thanks for Help!
AJ
Try this code, It will work fine.
Please find below code:
trigger demoTrigger on Contact (before update) {
set<ID> acctIds= new set<ID>();
for(Contact ct:trigger.new)
{
acctIds.add(ct.accountID);
}
List<Account> accts=[select id, name,Text1__c,BillingAddress,BillingStreet from Account where id in :acctids];
for(contact ct:trigger.new)
{
if(accts.size()>0)
{
ct.Mailingstreet =accts[0].billingstreet;
}
else
{
ct.Mailingstreet ='';
}
}
}
Hi can you tell me how to write test class for the code