5

I have a requirement where a user should not be able to close a case if the case owner is a queue. For that I have added a validation rule which goes like this

 BEGINS(OwnerId, "00G")&&IsClosed

This rule only works if I close the case second time(i.e. button is clicked twice). I want this rule to fire as soon as someone clicks on the Close Case button.

How should I change my formula for this rule.

5

You can't, because the validation rule only fires when an actual DML operation occurs. The first time, no DML operation occurs because the Close Case button just takes the user to a page where they can try to close the case (similar to if they click Edit, they are simply taken to a page where they can try to edit the case). It isn't until they actually attempt to close the case that the validation rule will be evaluated (e.g. the close case page's close case button).

If you want to display an error message immediately, consider a Visualforce page that overrides the Close Case button. This will give you an opportunity to display the message before they have a chance to try and close the case. You should still leave the validation rule in place if you want to enforce the business logic at the database level as well.

2
  • So can I create a trigger which will display an error message in such situation? – Yash Mehta Nov 11 '13 at 17:36
  • 4
    No, a Trigger only fires on DML operations, which is the problem you're having now. Your VF controller would have to enforce the rule on the UI side. – Mike Chale Nov 11 '13 at 17:48
0

Why not just prevent users from saving records if the Queue owns them. Everyone learns very quickly this way to accept records and then work them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.