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
Ganesh HegdeGanesh Hegde 

Add new button to Case List View


I have a requirement to show the List View buttons based on logged in User's Profile.

For example if System admin logs in he should see all 5 buttons - New Case, Accept, close, change owner, change status.
If other user logs in he should see only close button.

Can you please suggest me how can we achieve this? I am not finding any way to control the access to buttons. I am ready to develop visual force page also. But how can i replace Standard Case list view with visualforce page?

Any help/suggestion will be highly appreciated.

Thank YouUser-added image
Hi Ganesh,

You are correct that we do not have the privilege to show/hide buttons based on the profiles or any other stuff. But, you can control this in the below given way. This approach does not hide buttons from the unauthorized users but your requirement can be fulfilled. 
1. Create a custom button
2. Run javascript on click of it
3. Check the user profile in the script
4. Throw an alert saying "Insufficient Privileges", if the user is unauthorized to that button based on his/her profile.
5. Redirect to the respective url, for the authorized users.

Give a try on this and let me know if it blocks you anywhere. Hope this helps.

- Harsha
Ganesh HegdeGanesh Hegde
Hi Harsha,

Thanks for your valuable feedback. If i create a custom button how can i capture the record information in it?

I have created a button "In Progress" (See above image)-> this should change the status to inprogress for selected records. However I am not able to capture the selected record information to do the action, because the checkbox ID is in standard page.

Please suggest
Try the "Mass Update And Edit" package in APPEXCHANGE, which is an unmanaged one. This may help you to do this.

- Harsha
Ganesh HegdeGanesh Hegde
I have added below code for multiple record updates. Along with that i have added profile validation as you suggested. Its working

var records = {!GETRECORDIDS($ObjectType.Case)}; 
var newRecords = []; 

if (records[0] == null) 
alert("Please select at least one row") 
for (var n=0; n<records.length; n++) { 
var c = new sforce.SObject("Case"); = records[n].trim(); 
c.Status = "Eligible"; 

result = sforce.connection.update(newRecords);