Skip to main content
Anthony Bryant a posé une question dans #Data Management
I found a great trigger that I am currently re-engineering for my own needs.  What I am trying to accomplish is when a opportunity stage reaches "Closed Won" a field on the account object type will equal "customer".  I have copied what I have so far, just need some help to push me over.  I have also included the error mesage as well.

 

Thanks for your help!!!!

 

Error: Compile Error: unexpected token: '<' at line 1 column 8

 

trigger account_type on Account (before insert, before update) {

 

}trigger updateactive on account (after update){

opportunity__c[] cpstoupdate = new opportunity__c[]{};

for(account c : trigger.new ){

for(opportunity_c cp: [ select id,name,Closed_Won__c from stage__c  whereaccount=:c.id]){

if ( c.Closed_Won__c != Type && cp._Customer__c ){

cp.Prospect__c == false;

}

cpstoupdate.add(cp);

}

}

if(cpstoupdate.size()>0)

update cpstoupdate;

}

6 réponses
  1. 20 juil. 2011, 19:37
    You can do this without a trigger using a workflow. Create a rollup summary field at the Account. Make it a Count of opportunities. Add the Filter Critweria of Won = True. Then create a WFR that will update the Account Type field to customer when the rollup summary field > 0
0/9000