We have Email-to-case implemented which is assigning new cases to a Queue. Now whenever a user opens a new case, it should be assigned automatically to that user. For this I have written a VF page with a Controller. As soon as a user opens a case, the controller changes the Case owner to that user. So far so good!

Now, user should also be able to re-assign the case back to the queue (for somebody else to pick up or any other reason). But when he re-assigns, the same controller assigns it back to the same user immediately. This is happening because the case re-opens after owner is changed to the queue and thus the VF controller executes.

Is there a way I can get around it?

  • Are the users members of the queue?
    – sfdcfox
    Oct 11, 2018 at 19:01
  • Yes. Customer Service Queue
    – Maneesh
    Oct 11, 2018 at 19:04

1 Answer 1


Presuming the users are members of the queue they're looking at, you could just add the Accept button on the page layout. This single click button automatically assigns the case from the queue to the user. This would solve the problem of your Visualforce page continually reassigning the case back to the user.

In the more general sense, you should never create a page that automatically performs an action on page load, because of the potential for abuse. For example, user A could copy a link and email it to user B, and trick them into accepting the case. This is a CSRF vulnerability and should be avoided at all costs.

You must log in to answer this question.

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