You need to sign in to do that
Don't have an account?
Sakthivel Thandavarayan
Need help with javascript custom button to mass update & refresh list views
Hi there, The below script works well on case list views. however the problem is with the refresh, after the page refresh list view changes to something else. It not showing the selected list view, instead it's showing the first view or random(not sure).
Is there way to update records, refresh the list view and select the same list view ?
{!REQUIRESCRIPT("/soap/ajax/34.0/connection.js")}
var records = {!GETRECORDIDS($ObjectType.Case)};
var newRecords = [];
if (records[0] == null)
{
alert("Please select at least one row")
}
else
{
for (var n=0; n<records.length; n++) {
var c = new sforce.SObject("Case");
c.id = records[n];
c.Status = "Canceled";
c.ownerid='{!$User.Id}';
newRecords.push(c);
}
result = sforce.connection.update(newRecords);
window.location.reload();
}
Is there way to update records, refresh the list view and select the same list view ?
{!REQUIRESCRIPT("/soap/ajax/34.0/connection.js")}
var records = {!GETRECORDIDS($ObjectType.Case)};
var newRecords = [];
if (records[0] == null)
{
alert("Please select at least one row")
}
else
{
for (var n=0; n<records.length; n++) {
var c = new sforce.SObject("Case");
c.id = records[n];
c.Status = "Canceled";
c.ownerid='{!$User.Id}';
newRecords.push(c);
}
result = sforce.connection.update(newRecords);
window.location.reload();
}
But if Reload does not work for you, you can use Replace:
replace(url):Replace the current document with the one at the provided URL.
so it would be
window.location.replace("YOUR URL");
YOUR URL can be relative to Salesforce server like
location.replace("/{!Case.Id}?retURL=%2F{!Case.Id}");
thx
Reload is working fine. but after the reload, its going to random list view, not the one that was previously selected.
Consider I have 5 list views, and I'm in 3rd view now.
when I click the button, page reloads and list view selected now is not 3rd view. but 1st view.
I want to reload the page and select the same list view where user left. Is that helps understanding my issue ?
window.location.href = "/500";
Both works. Still there is an issue without styling. Sorry for not mentioning it in the question as I'm not aware this will cause UI changes.
This button is placed in case list view and users using this button on (service)console app. After winter 16 release, console list view UI changed little bit compared to the actual list view(non console apps).
After updating the script with the solutions you provided, it redirects properly to the same list view but UI changed.
Before clicking the button
After
Any idea what I'm missing ?
Did you ever resolve this issue, we are encoutering it in our org as well, specificaly with the console the button works fine outside of that.
R