function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JoaxJoax 

Semi-automatic function in Cases that assign cases to a user

We want our customer service users to assign, let say 5 new cases, to themselves with a click on a button. 
We don't want them to see all of the cases, and get stressed, and have the possibility to pick any of these.
The unassigned cases has a queue as the owner. When these 5 cases are solved by the user, he/she clicks on the button "give me 5 new cases" and the cases with the higest priority changes owner to the specific user. The solved cases changes the owner back to the queue, via a workflow rule. Does anybody know if there is some kind of function/app that handles the "give-me-new-cases"-function?
*werewolf**werewolf*

See this blog post for a simple solution.

JoaxJoax

Hi!

Thanks for the solution.

Though I have a problem with this, I get an error-message when I click on the button that says:

"A problem with the OnClick JavaScript for this button or link was encountered.

 

{faultcode:'soapenv:Client',

faultstring:'System.QueryException: List has no rows for assignment to SObject

 

Class.RetreiveNextUtils.retreiveNextCase: line 16, column 28 External entry point'. }"

 

Could you tell me why I get this error?

I have added the Apex class, and added the custom button as a "Detail Page Button" with behaviour "Execute JavaScript" and Content Source "OnClick JavaScript".

Have I missed anything?

 

 

Perhaps we need the possibility to give the support agent, lets say 5 cases at the time, but I hope it is possible to modify this so that it could handle this as well.

 

 

*werewolf**werewolf*

My first guess is that your user is not in any queues.  My second guess is that there is no next case for him (although the code should handle that case gracefully I think, since one of the test methods included with the code tests for that).

JoaxJoax

It was the queue-thing. The user wasn't member of the appropriate queue. I found that out the same moment you answered...

 

Is it possible to add this button on the List view instead of the Detail page? What do I have to change in that case? I tried to add the same button as a List button, but I got an error, "Cannot call method 'execute' of undefined".

 

In any case, thanks for a great solution!

*werewolf**werewolf*

Actually it's working just fine for me as a list button also.  You did set that button to Execute Javascript, right?

 

Note that I've updated the code on the wiki page to fix some of the tests on the Apex class that were failing.  You may want to update your RetrieveNextUtils class correspondingly so that you get good test coverage with it.

JoaxJoax

It worked just fine for me now. Thanks a lot!!

 

Just one more question. We need this function to get the next prioritized case in line. A two day old case with high priority should be assigned before a two hour old case with low priority. Is that possible? How is the cases selected today? Is it some kind of random selection, or is it just by date?

We tried to add the ORDER BY functionality when we selected the case for update, but it didn't seem to support that function.

*werewolf**werewolf*

Well, the Apex doc does say:

 

You cannot use the ORDER BY

keywords in any SOQL query that uses locking. However, query results are automatically ordered by ID.

 

So I guess not.  You could remove the FOR UPDATE from the statement, although that could lead to race conditions in which, if 2 users are in the same queue and press the button at nearly the same time, they might get the same case.  Somewhat unlikely (they would have to press the button within milliseconds of each other).

JoaxJoax

That's the same thing we found in the documentation as well, but I just wanted to check if there was some kind of workaround.

I think we will try to remove FOR UPDATE, and hope that two agents do not press the button at the same time.

 

Your solution helped us a lot, so thanks again!

Thomas RasmussenThomas Rasmussen

Hi there, I know this is an old post. But I was wondering if you figured out a solution to this? I'm trying to prioritize based on a custom priority field we have that lists priority from 100 to 0. Did removing For Update solve it for you or did you end up finding a more "safe" option for this?

 

Thanks

 

Thomas R