-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathUpdateContactAddInfo
More file actions
34 lines (31 loc) · 1.13 KB
/
Copy pathUpdateContactAddInfo
File metadata and controls
34 lines (31 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
global class UpdateContactAddInfo implements Database.Batchable<sObject>
{
global Database.QueryLocator start(Database.BatchableContext bc)
{
return Database.getQueryLocator(
'SELECT ID, BillingStreet, BillingCity, BillingState, ' +
'BillingPostalCode, (SELECT ID, MailingStreet, MailingCity, ' +
'MailingState, MailingPostalCode FROM Contacts) FROM Account ' +
'Where BillingState = \'TX\''
);
}
global void execute(Database.BatchableContext bc,List<Account> scope)
{
List<Contact> contacts=new List<Contact>();
for(Account account:scope)
{
for(Contact contact:account.contacts)
{
contact.MailingStreet=account.BillingStreet;
contact.MailingCity=account.BillingCity;
contact.MailingState=account.BillingState;
contact.MailingPostalCode=account.BillingPostalCode;
contacts.add(contact);
}
}
update contacts;
}
global void finish(Database.BatchableContext bc)
{
}
}