Current Setup: Workflow rules are creating task assigned to a specific opportunity role. A trigger (written by a developer who has left the organization) associates value in business_associate__C picklist to the opportunity team with the specific role. It also limit 1 user to this role on the opportunity team.
New Business need: Once the task is created the subject needs to updated with the name in the Business_Associate__C field. Additional the value of the Business_Associate__C picklist on the opportunity needs to be pushed to a matching picklist on the task.
Since a workflow can not trigger another workflow, a task trigger needs to be created to update the task.
This is what I have put together so far... Not sure how associate values from related opportunity to the tasksToUpd map for update.
Trigger TaskTrigger On Task (after insert)
//Establish variable for whatIDs
Set <String> whatIDs = new Set<String>();
//Loop New Tasks
For (Task t: Trigger.new) {
whatIDs.put(t.WhatID, t);
}
//List opportunities gathered from Task loop
List <Opportunity> oppty = [Select ID, Business__Associate__C from Opportunity WHERE ID =: whatIDs];
//Create Map for tasks to update
Map <String, Task> tasksToUpd = new Map <String, Task> ();
For (Task t : Trigger.new) {
tasksToUpd.put(t.whatID, t);
}
//Loop through opportunities, gather
For (Opportunity o: oppty) {
if (tasksToUpd.containsKey(o.ID)){
***[Get Business_Associate__C Value and Store in TasksToUpd Maps - TasksToUpd.Business_Associate__C]***
***[Get Business_Associate__C Value and Replace last two characters of subject 'BA' and store in TasksToUpd Maps - TasksToUpd.Subject]***
}
Update TasksToUpd;
Any help will be appreciated. Thanks in advance.