Skip to main content
trigger on events/tasks after insert and after update to update a field on opportunity,with the value of field in events/tasks..
5 Antworten
  1. 27. Juli 2016, 12:10

    I think I figured it out. Thanks for the code!

    Trigger changeopp on Event(after update, after insert) {

    string eid;

    list<opportunity> oplist = new list<opportunity> ();

    list<opportunity> opToUpdate = new list<opportunity> ();

    for (event e: trigger.new) {

    eid= e.whatid;

    if(eid.startsWith('006')) {

    oplist = [select name, stagename from opportunity where id=: eid and (stagename= 'Contacted' or stagename= 'Start - go for it!')];

    }

    }

    for ( opportunity opp: oplist) {

    opp.stagename = 'Appointment scheduled';

    opToUpdate.add(opp);

    }

    update opToUpdate;

    }

0/9000