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.

2 Answers 2


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.

  • So can I create a trigger which will display an error message in such situation?
    – Yash Mehta
    Commented Nov 11, 2013 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
    Commented Nov 11, 2013 at 17:48

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .