+ Start a Discussion

Account.Type should be changed upon an Opportunity stage

Hey All,


When Opportunity Stage== Received Specimen,

then Account.Type should be changed to "Customer".


Is apex trigger used to accomplish the task???Please suggest me. Any code provided, is appreciated.


Thanks-- Deepthi


It can -- use a trigger to make the change.


Docs are here.  YOu can find links to more examples.


Thank you!!!

Yes, it can be done with the help of a trigger.

Can you please provide me with the code.


trigger AccountTypeUpdate on Opportunity (after update) {
list<Account> accounts = new List<Account>();
Set<String> accSet = new Set<String>();

for(Opportunity opp : Trigger.new) {
if (opp.StageName == 'A - Closed Won') {
accounts = [Select ID, type from Account where ID in :accSet];
for(Opportunity opp : Trigger.new){
for(Account acc:accounts){

if(opp.AccountId == acc.Id && opp.StageName == 'A - Closed Won' && opp.Deal_Category__c=='OD'){
acc.type = 'Customer - OD';
if (opp.Accountid == acc.id && opp.StageName == 'A - Closed Won' && opp.Deal_Category__c=='Perpetual'){
acc.type = 'Customer';
if(accounts.size() > 0){
update accounts;



Thanks a lot Steve!!!

It worked...Thanks