Created
June 14, 2022 23:05
-
-
Save jvolkov/55a7654c46521ec0ee4cb377c3beee5c to your computer and use it in GitHub Desktop.
create salesforce campaign member statuses
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
// change the campaign id and status to the correct values | |
Campaign campaign = [SELECT Id FROM Campaign WHERE Id = 'ENTER THE CAMPAIGN ID' LIMIT 1]; | |
List<CampaignMemberStatus> newStatusesToInsert = new List<CampaignMemberStatus>(); | |
List<String> statuses = new List<String>{'Ideal User', 'MQL', 'Assigned', 'Touched', 'Disqualified', 'Clicked', 'Demoed', 'Opportunity', 'Won'}; | |
for (String status: statuses) { | |
system.debug(status); | |
CampaignMemberStatus newStatus = new CampaignMemberStatus (); | |
newStatus.Label = status; | |
newStatus.CampaignId = campaign.Id; | |
newStatus.HasResponded = true; | |
newStatusesToInsert.add(newStatus); | |
} | |
Database.SaveResult[] results = Database.insert(newStatusesToInsert, true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment