Skip to content

Instantly share code, notes, and snippets.

@anmolgkv
Created May 26, 2024 10:16
Show Gist options
  • Save anmolgkv/2e17e7812e8b5902ca452dd84e2a7a09 to your computer and use it in GitHub Desktop.
Save anmolgkv/2e17e7812e8b5902ca452dd84e2a7a09 to your computer and use it in GitHub Desktop.
createTasksForNewAccounts
public void createTasksForNewAccounts(List<Account> newAccounts) {
List<Task> tasks = new List<Task>();
for(Account account : newAccounts) {
Task newTask = new Task();
newTask.WhatId = account.Id;
newTask.OwnerId = account.OwnerId;
newTask.Subject = getTaskSubject(account);
tasks.add(newTask);
}
try {
insert tasks;
} catch (Exception e) {
Logger.logError(tasks, e);
}
}
private String getTaskSubject(Account account) {
String taskSubject = 'Schedule call for new standard account';
Boolean isPartnerAccount = AccountDomain.isPartnerAccount(account);
Boolean isCustomerAccount = AccountDomain.isCustomerAccountAccount(account);
Boolean isGoldTier = AccountDomain.isGoldTier(account);
Boolean isSilverTier = AccountDomain.isSilverTier(account);
if(isPartnerAccount && isGoldTier) {
taskSubject = 'Schedule call for new Partner account';
} else if(isCustomerAccount && isSilverTier) {
taskSubject = 'Schedule call for new Customer account';
}
return taskSubject;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment