0

In the console settings for apps there is a refresh feature for lists. If we select refresh list rows, it doesnt actually refresh. It only highlights the rows that were changed. Is it possible to make the list refresh instead of highlight?

enter image description here

This is needed because customer service users use these lists to assign cases to themselves. We need the list to refresh so users are not tripping over each other

1

Sorry for the late response, but I came across your question when looking for something else. Hopefully you found what you need, but just in case, here's two concepts that we use:

  1. Use a user script in the browser to refresh the view every few minutes - we use Chrome as the browser and the Tampermonkey plugin to load the user script

  2. Create a button in Salesforce called "Assign To Self" which you put on your page layouts and it runs JavaScript to retrieve the current owner of the Salesforce case before assigning the case (checks if it's assigned to a User rather than a Queue, assuming that all your "New" cases get assigned to a Queue). It also sets the status as In Progress. So if two users go into the case to view at the same time and one of them assigns it to themselves, the second person, on clicking the Assign To Self button, will get a popup saying the case has already been assigned and names the person it is assigned to.

Naturally, you'll want some code...

-

For the browser user script, you need two bits of info that will be specific to your Salesforce organisation - the Salesforce URL and the Refresh button id.

Page Url is easy enough if you use standard Salesforce Apps, but if you use the service console apps, then the URL is in the frame, so right click the frame in your browser and View Source - you'll see the frame url is part of the source url.

For the button ID, just right-click the refresh button in the Salesforce list view and click Inspect Element - the id will be something like 00Cc000000Dabc_refresh.

Now the userscript code (replace the parts you need from info above):

// ==UserScript==
// @name        Company\Refresh-Cases
// @namespace   Company\Refresh-Cases
// @description Company\Refresh-Cases - Refreshes Support Cases page every 3 minutes
// @include     https://eu2.salesforce.com/500?fcf=00Xx0000009Xxxx*
// @exclude     %exclude%
// @version     1.00
// @grant       none
// ==/UserScript==

// Setup function to click refresh button a set number of minutes
// (change var minutes to wait for a different time period)

var minutes = 3;

setInterval(function(){
  document.getElementById('00Cc0000002abcd_refresh').click();
}, ((1000 * 60) * minutes ));

// Click button on page load
document.getElementById('00Cc0000002abcd_refresh').click();

-

For the Assign to Self button, create a new button or link, give the button a label (e.g. Assign To Self) and make it a Detail Page Button with Behaviour = Execute Javascript and Content Source = OnClick JavasScript.

And now for the Button code (in the code below there's a check to see if the function srcUp exists - this is to check if the case has been opened in the service console and plays nicer with the tabs this way):

{!REQUIRESCRIPT ("/soap/ajax/30.0/connection.js")}

var caseid = "{!Case.Id}";
var userid = "{!$User.Id}";
var CaseToUpdate = new sforce.SObject("Case");
var casestatus = "{!Case.Status}";
var caseowner = "{!Case.OwnerId}";
var caseids = [caseid];
var assigncontinue = true;

var realcaseowner = sforce.connection.retrieve("OwnerId", "Case", caseids);

if (realcaseowner[0].OwnerId.substring(0, 3) == "005") {
    var ownerids = [realcaseowner[0].OwnerId];
    var realcaseownername = sforce.connection.retrieve("Name", "User", ownerids);
    assigncontinue = confirm("Case already assigned to " + realcaseownername[0].Name + "! Do you wish to assign to yourself?");
}

if (assigncontinue) {
    if (casestatus == "New") {
        CaseToUpdate.set("Status", "In Progress");
    }

    CaseToUpdate.set("Id", caseid);
    CaseToUpdate.set("OwnerId", userid);
    var Result = sforce.connection.update([CaseToUpdate]);
    if(Result[0].getBoolean("success"))
    {
        function redirect() {
            if (typeof(srcSelf) == 'function') {
                srcSelf('/{!Case.Id}');
            }
            else {
                window.top.parent.frames.location.replace("/{!Case.Id}");
            }
        } 
        redirect(); 
    }
    else {
        alert("Error");
    }
}

-

I hope this helps in some way, but even if it doesn't it's good to get this up somewhere for someone else to use in the future.

Disclaimer: I am not a Salesforce Dev, just an I.T. bod, so don't be surprised if the code is a bit crude. However it currently works fine in everyday use for what I need it for.

2
  • We have the same problem. Can you explain me in detail your solution with Tampermonkey? I follow your example, using my Org data, but it seems not working at all. Jul 24 '17 at 15:32
  • @L.benedettini There's quite a bit of detail above. Make sure you have the correct URL and the correct ID for the button. If the TamperMonkey icon doesn't have a "1" in it, then it hasn't seen that you are on the right page. If it has a "1" in the icon, then you probably have the wrong ID for the refresh buton. Aug 3 '17 at 21:19

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.