You need to sign in to do that
Don't have an account?
sudhirn@merunetworks.com
Update Account Type field when Opportunity is approved
Hi,
I wrote a workflow to update account type when opportunity approval is approved ( approval in opportunity is tracled through a flag called status) but this is failing please suggest me I even wrote a trigger to update this is not firing when approval is approved when edited it is working
Please suggest me
Thanks
Sudhir
I wrote a workflow to update account type when opportunity approval is approved ( approval in opportunity is tracled through a flag called status) but this is failing please suggest me I even wrote a trigger to update this is not firing when approval is approved when edited it is working
trigger Account_Type_Update on Opportunity (After Update) { Public List<Opportunity> Optys = New List<Opportunity>(); Public List<Account> Acct = new List<Account>(); Optys = [SELECT Id,AccountID,Account.ID,Account.RecordTypeID, RecordType.name,RecordTypeID,Is_Approved__c FROM Opportunity WHERE Id = :Trigger.newMap.keySet() ]; for ( Opportunity Opp : Optys ) { if ( (Opp.RecordTypeID == '012250000008i5uAAA' || Opp.RecordTypeID == '01225000000ChlOAAS' || Opp.RecordTypeID == '01225000000ChlEAAS' ) && Opp.Is_Approved__c == True) { Acct = [SELECT RecordTypeID,Type FROM Account WHERE ID = :Opp.AccountID ]; for ( Account Act : Acct ) { Act.Type = 'Client'; Update Act; } } } }
Please suggest me
Thanks
Sudhir
1) The trigger is not bulkified. You have SOQL and DML statements in a loop.
2) Your for-loop is probably not executing because you can't loop through a single object.
Try this:
Hope that helps,
Clint
All Answers
1) The trigger is not bulkified. You have SOQL and DML statements in a loop.
2) Your for-loop is probably not executing because you can't loop through a single object.
Try this:
Hope that helps,
Clint
Thans for your reply tried your method its not working any other suggestion
Thanks
Sudhir
You've verified that the Opportunity you are updating has one of the Record Type Ids in your if-statement and that the Is_Approved__c field is checked?