You need to sign in to do that
Don't have an account?
Steve Harrison
Need apex trigger code for updating Opportunity stage when quote is emailed
Hello,
I want the Opportunity stage to update to the "Proposal/Price Quote Sent" picklist value when a quote is emailed. I was not successful at creating a workflow rule and field update and the user forum indicated this is only possible through an apex trigger. If this is correct, can someone provide me the code or other suggestions?
Thanks
Steve
I want the Opportunity stage to update to the "Proposal/Price Quote Sent" picklist value when a quote is emailed. I was not successful at creating a workflow rule and field update and the user forum indicated this is only possible through an apex trigger. If this is correct, can someone provide me the code or other suggestions?
Thanks
Steve
Based on your previous feedback, here is the code submitted with compile errors. You were missing two variables on lines #2 and #3.
This code is cleaned up a bit and fixes a few bugs in the previous code. There is one final assumption here. The code previously submitted does not handle after update, which I recommend you handling. Not all Tasks are created directly as 'Completed', and they are updated (sometimes multiple times) before reaching a Completed status. You will want to add the 'after update' event and check that your fields have changed from your previous task's values compared to the current task's values. Look at Trigger.oldMap and do something similar to Task oldTask = Trigger.oldMap.get(task.Id); to get the previous task's values/state for your comparison purposes. This way you are not blindly running updates on Opportunities that might not need it when driving fields have not been changed.