You need to sign in to do that
Don't have an account?
Nick Mirams
Trigger to update the task status after opportunity status is won or lost
Hi,
Can someone help as i am pretty new to all this...
I want to write a trigger on the task which updates the task status to completed after the oipportunity is set to Closed Won or Closed lost.
This is to basically prevent any closed opportunities which still have open tasks.
Its an if statement of some sort but I need to learn how to do all this
Thanks in Advanced.
Nick
Can someone help as i am pretty new to all this...
I want to write a trigger on the task which updates the task status to completed after the oipportunity is set to Closed Won or Closed lost.
This is to basically prevent any closed opportunities which still have open tasks.
Its an if statement of some sort but I need to learn how to do all this
Thanks in Advanced.
Nick
My bad, i re-used the same variable name. Please replace the code with the code below and add the new stagename for opp like you did before.
All Answers
please try the code below. If that solves your problem, please like this answer and mark this as the best answer.
Thanks,
Rohit
Thanks for your help so far....
I got a compile error at line 28 saying duplicate variable?
I am doing this in the test environemnt and also added in another opportunity status of .....|| opp.StageName='Closed No Longer Required'
any ideas?
Thanks for your help
Nick
My bad, i re-used the same variable name. Please replace the code with the code below and add the new stagename for opp like you did before.
Compile Error: OR operator can only be applied to Boolean expressions at line 26 column 36...
I have as the code: -
if(opp.stagename=='Closed Lost' || opp.stagename='Closed Won' || opp.stagename='Closed No Longer Required'){
can you help again you very helpful person?
You are using single "=" in comparison, it shoud be double "=" sign. Like below
If that solves your query, please like this post and mark this as the best answer.
Thanks
Rohit
Compile Error: Trigger name exists on different SObject type...
ive changed it a few times and still reveive the same error
may spend some more time learning this stuff.....
think i'm gonna try and learn some more coding, seems fun
Please like the post, and mark it as the best answer if that solves your query.
Thanks,
Rohit
I found this code very useful and installed it in my sandbox to test. Worked perfectly in the sandbox but when I tried to deploy to my production org that has the opp pusher intalled, I received the following error:
OppPusherTestsmyOppUnitTestSystem.AssertException: Assertion Failed
Stack Trace: Class.OppPusherTests.myOppUnitTest: line 37, column 1
Can you offer any help?
Thanks,
Brian