Last active
March 31, 2017 13:31
-
-
Save goravseth/657621611e5d4d5b2190016ccb14ed80 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
will create campaign member records for all contacts and all campaigns | |
campaign member status will split between sent and responded | |
this is to for creating test records in developer orgs | |
it will fail with large numbers of records | |
*/ | |
List<campaign> cl = new list<campaign>([select id from campaign); | |
List<contact> conlist = new list <contact>([select id from contact]); | |
List<campaignMember> cmlist = new list <campaignMember>(); | |
integer counter = 1; | |
for (Campaign cam : cl){ | |
for (Contact c : conlist){ | |
campaignmember cm = new campaignmember(); | |
cm.contactId = c.id; | |
cm.campaignId = cam.id; | |
IF(math.mod(counter,2) == 0){ | |
cm.status = 'responded'; | |
} | |
ELSE(cm.status='sent'); | |
cmlist.add(cm); | |
counter += 1; | |
} | |
} | |
insert cmlist; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment