• bek123nyc
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 5
    Replies

i've created below trigger to update a specific Account field whenever an Opportunity goes to 90%. 

While the trigger seems to be firing, the update to the Account is not taking place.

 

Snippet from debug log also provided at bottom...

 

 

 thanks for any help you can provide...

 

 

 

 ==================

 

trigger AddToParatureAt90 on Opportunity (after update) {
  List<id> acctIds = new List<id>();
  for(Opportunity opp: Trigger.new) {
  
  
    if (opp.StageName == '90-Closed-Signed') 
            {acctIds.add(opp.AccountId);}
         }
 
    List<account> accounts = [SELECT a.Id FROM Account a WHERE a.Id IN :acctIds];

    for (Account a: accounts) {a.AddParatureAccount__c ='Yes-Add' ;}
    
    update accounts;
  }

===============

Debug Log Snippet

05:20:58.658|CODE_UNIT_STARTED|[EXTERNAL]OpportunityAcctPhoneNumber on Opportunity trigger event AfterUpdate for 006T00000053bhx
05:20:58.658|SOQL_EXECUTE_BEGIN|[10,30]|Aggregations:0|SELECT a.Id FROM Account a
WHERE a.Id IN :acctIds
05:20:58.661|SOQL_EXECUTE_END|[10,30]|Rows:0|Duration:3

 

i've created below trigger to update a specific Account field whenever an Opportunity goes to 90%. 

While the trigger seems to be firing, the update to the Account is not taking place.

 

Snippet from debug log also provided at bottom...

 

 

 thanks for any help you can provide...

 

 

 

 ==================

 

trigger AddToParatureAt90 on Opportunity (after update) {
  List<id> acctIds = new List<id>();
  for(Opportunity opp: Trigger.new) {
  
  
    if (opp.StageName == '90-Closed-Signed') 
            {acctIds.add(opp.AccountId);}
         }
 
    List<account> accounts = [SELECT a.Id FROM Account a WHERE a.Id IN :acctIds];

    for (Account a: accounts) {a.AddParatureAccount__c ='Yes-Add' ;}
    
    update accounts;
  }

===============

Debug Log Snippet

05:20:58.658|CODE_UNIT_STARTED|[EXTERNAL]OpportunityAcctPhoneNumber on Opportunity trigger event AfterUpdate for 006T00000053bhx
05:20:58.658|SOQL_EXECUTE_BEGIN|[10,30]|Aggregations:0|SELECT a.Id FROM Account a
WHERE a.Id IN :acctIds
05:20:58.661|SOQL_EXECUTE_END|[10,30]|Rows:0|Duration:3

 

I am very new to salesforce, and even newer to Apex.  I'm trying to update a field on my account object, after an opportunity has been closed - won. Here is my first attempt;

 

trigger AccountTypeUpdate on Opportunity (after update) {
   
    Account myAccount=trigger.update[0];
    if (opportunity.StageName = 'A - Closed Won') {
     myAccount.type = 'Customer';
     update myAccount;
    }    //else nothing
}

 

Evidently it doesn't work, and I realize I would have to select the account associated with that opportunity, I'm just not sure how to go about doing that.  Any help would be greatly appreciated.