Created
May 26, 2024 10:16
-
-
Save anmolgkv/2e17e7812e8b5902ca452dd84e2a7a09 to your computer and use it in GitHub Desktop.
createTasksForNewAccounts
This file contains hidden or 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
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