+ Start a Discussion
Stephanie AkinStephanie Akin 

Help with trigger

Hi. A friend helped me develop a trigger for when an activity with the subject File Forms from Recruit in EE Folder is changed to the status of completed it updates the opportunity stage to Day 1 Complete. 

But I am getting an error and I can't figure out why. Error: Compile Error: Variable does not exist: trigger at line 4 column 18

Any help is appreciated. 

Here is the code:

trigger updateStatus on Task (after insert, after update){
    List<Id> oppy_ids = new List<Id>();
    List<Opportunity> update_oppys = new List<Opportunity>();
    for(Task t : trigger.new()){
        //when subject is this, the opp should be start 10 day cycle
        if(t.Subject == 'File Forms from Recruit in EE Folder' && t.Status == 'Completed' && t.WhatId != null && String.valueOf(t.WhatId).startsWith('006')){

    for(Opportunity o : [SELECT StageName FROM Opportunity WHERE ID IN :oppy_ids]){
        // or whatever you need the stage  name to be
        o.StageName = 'Day 1 Complete';
        //add the opportunity to a list for dml

        update update_oppys;
Best Answer chosen by Stephanie Akin
Prabu MahalingamPrabu Mahalingam
Simple fix just replace trigger.new() with trigger.new.  ie remove the round brackets ().