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
I have written test case for this trigger.but can anyone tell me where is wrong in this...
trigger copystreetaddress on JunctionObject__c (before insert){ if(trigger.isInsert) { Set<Id> accountId = new Set<Id>(); Set<Id> contactId = new Set<Id>(); for(JunctionObject__c tempJ : Trigger.new) { accountId.add(tempJ.Account__c); contactId.add(tempJ.Contact__c); } List<Account> AccountList = [Select id,Name,BillingStreet from Account where id in: accountId]; List<Contact> ContactList = [Select id,Name,OtherStreet from Contact where id in: contactId]; for(JunctionObject__c tempJ : Trigger.new) { for(Account tempAcc : AccountList) { if(tempJ.Account__c == tempAcc.Id) { for(Contact tempCon : ContactList) { if(tempJ.Contact__c == tempCon.Id) { tempCon.OtherStreet = tempAcc.BillingStreet; } } } } } update ContactList; } }
From what you're attempting to do here in this example a formula field will do the job just fine. There's no need for a trigger.
From what you're attempting to do here in this example a formula field will do the job just fine. There's no need for a trigger.