You need to sign in to do that
Don't have an account?
Anthony Moss
Update Task status based on field change in parent record
New to Apex. Trying to create a trigger that would update the status field of a task based on a field update in the parent (specifically opportunity) record? Can anyone help me out? Thanks in advance!
Follow the below steps,
1. Goto Setup->Create->Workflow&Approval->Process Builder
2. Click New and enter the name for the process
3. Click 'Add Object' and select Object as "Opportunity" and select "when record is created or edited"
4. Set the criteria in which you want to update the task object
5. Click "Add action" and select "Update Record" as Action Type
6. Choose "Tasks" in the Object
7. Select the field you want to update in the task and Save your action
8. Click "Activate"
Hope this reolves your problem without writting a trigger
Use this code :
trigger OpportunityTest on Opportunity (after update) {
set<string> setOpp = new set<string>();
for(Opportunity opp : Trigger.New){
//put if condition which check on which field update
setOpp.add(opp.Id);
}
list<Task> listTask = new list<Task>();
for(Task t : [Select Status from Task where WhatId IN : setOpp]){
t.Status = 'Not Started';
listTask.add(t);
}
if(listTask.size() > 0)
update listTask;
}
If this answers your question then hit Like and mark it as solution!
id' of all task related to that lead reocrd. Please help