You need to sign in to do that
Don't have an account?
Everton CP7
Case doesn't close if have tasks opened
I'm trying to do a trigger that doesn't let anyone close the case if I have tasks opened in the case.
If you try to close the case an error will appear.
Code:
trigger ChamadoAbertoTarefaAberta on Case (after update) { { List <Task> statuslist = [SELECT id, Status FROM Task WHERE WhatId IN :trigger.new AND Status statuslist.add(t.WhatId, true)]; MAP<id,string> statuslist= new LIST<Id,String>(); for(Task t : trigger.new) } for(Case c : trigger.new()){ if(map.get(c.Id) == true){ c.addError(My error here); } else{ break; } } }
I don't know where I'm going wrong.
Thanks for help !
Since you wanto to prevent the user from updating the Case to closed, you would want this trigger to fire "before update". I've commented up the following code for you to help ya out.
Let me know if you have any questions.
All Answers
Since you wanto to prevent the user from updating the Case to closed, you would want this trigger to fire "before update". I've commented up the following code for you to help ya out.
Let me know if you have any questions.
Thanks jbroquist !
I tried somethings and get errors with a couple of things.
I wrote some comments here and finally I decide to change "before update" to "after update" and it works.
Thanks you so much. I realy was in need.
I tried do the test class, but doesn't work too.
Can you help me in this code too?
Thanks again !!