function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Daniel MasonDaniel Mason 

Trigger which updates picklist value based on criteria

HI All
I need some help creating a trigger. This is my first time creating a trigger so my applogises if its incorrect.

Aim : Every time a task is created which meets criteria ( See below) then change the status (picklist) from “Not started” to “Completed”

The trigger should only fire if it meets the following criteria RecordTypeId = '0123000000007ZoAAI'

Type.contains 'meeting:'

Type.contains 'Call;'

Type = 'Other - see subject'

ownerid = 00E30000000gYL8 

I have attempted to create the following trigger, but I am not sure if I am on the correct lines

Really looking forward to your help
 
trigger UpdateStatus on Task (after insert) {

   for (Task t : trigger.new){
            if (t.RecordTypeId == '0123000000007ZoAAI'){
            if (t.Type.contains('meeting:')){
            if (t.Type.contains ('Call;'))
            if (t.Type = 'Other - see subject';
                    }
                }
            }
        }
}
// Need to include assigned to owner/
if(t.OwnerId == '00E30000000gYL8'){

Status = 'Completed':

 
StephenKennyStephenKenny
Hi Daniel,

Good news - you dont need a trigger to do this. A workflow rule and field update should be used to do this instead. Let me know if you need any help confoguring the workflow rule.

Please remember to mark this thread as solved with the answer that best helps you.

Regards
Stephen 
Daniel MasonDaniel Mason
i completely forgot about workflow rules ! i am such an idiot 
StephenKennyStephenKenny
Hi Daniel,

Dont worry, it can happen to the best of us :) Could you please remember to mark this thread as solved with the answer above so that others can find this thread more easily.

Thanks,
Stephen