You need to sign in to do that
Don't have an account?
submit opportunity for approval when stage is updated
I am trying to write a trigger that will send a Opportuinty to approval when the stage is set to "send to accountig" I dot get a error when I save the code but it does not work and I am not sure why.
trigger OpportunitySubmitForApproval2 on Opportunity (after update) {
for (Opportunity opp : Trigger.new){
if (opp.Stagename =='Sent To Accounting'){
Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
}
}
}
trigger OpportunitySubmitForApproval2 on Opportunity (after update) {
for (Opportunity opp : Trigger.new){
if (opp.Stagename =='Sent To Accounting'){
Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
}
}
}
Try that. Also, here is a link with a little walk through and some discussion on the topic: http://blog.jeffdouglas.com/2010/01/04/automating-salesforce-approval-processes-with-apex-triggers/
All Answers
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_process_example.htm
trigger OpportunitySubmitForApproval2 on Opportunity (after update) {
for (Opportunity opp : Trigger.new){
if (opp.Stagename =='Sent To Accounting'){
Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
req.setObjectId(opp.Id);
Try that. Also, here is a link with a little walk through and some discussion on the topic: http://blog.jeffdouglas.com/2010/01/04/automating-salesforce-approval-processes-with-apex-triggers/