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
Regina94Regina94 

Javascript custom list button not working for users (Insufficient Privileges)

I created a custom button which executes javascript (Mass Delete). For me as system administrator it’s working perfectly but my user receives “insufficient privileges” when clicking on this button. The user can delete one record, this is working. But not multiple records with this button.
 
The button is on a view list of my custom object Requested_Agencies__c. It is a junction object between Accounts and Campaigns. So my user has full access (CRUD, view all, modify all) on my custom object, Accounts, Campaigns, Contacts and Leads. Enable API is also checked.
 
I think there must be a permission for users to execute javascript buttons? Please help.
 
Here is the code:
{!REQUIRESCRIPT("/soap/ajax/38.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/38.0/apex.js")}
 
var records = {!GETRECORDIDS($ObjectType.Requested_Agency__c)};
var strIDs='';
if (records[0] == null)
{
alert('Please select a record');
}
else
{
for (var n=0; n<records.length; n++)
{
if(strIDs == '')
strIDs = records[n];
else
strIDs = strIDs + "," + records[n] ;
}
window.location.href = '/apex/MassManager__MassDelete?deleteIds='+strIDs + '&selectedObject=Requested_Agency__c&retURL='+ window.location.href;
}
 
Best Answer chosen by Regina94
LBKLBK
Hi Regina,

Javascript Button on a Custom Object does not have its own permission settings.

However, it could be the VF Page.

Can you check if your user has access to the VF page "MassManager__MassDelete"?

All Answers

LBKLBK
Hi Regina,

Javascript Button on a Custom Object does not have its own permission settings.

However, it could be the VF Page.

Can you check if your user has access to the VF page "MassManager__MassDelete"?
This was selected as the best answer
Regina94Regina94
Thank you!! Now it's working for the user :)
Chau Trang 9Chau Trang 9
Hi Regina94 and LBK,

How can I check if someone (user/admin) has access to  the VF page "MassManager__MassDelete"? I have the same error as an admin

Thank you!
LBKLBK
Hi Chau,

You can either add this VF page to the user's profile or a to a permission set and assign the permission set to the user.

When you edit a profile / permission set, you will find a  section (towards the bottom  of the screen) for Visualforce pages.
Chau Trang 9Chau Trang 9
Thank you LBK, that would do. And looks like I need to install the Javascript as well, as I check there is no such VF for this instance. Do you know where can I find those?
LBKLBK
Hi Chau,

These javascript files referred in the custom button code above are already present in the platform, you don't have to install them.

Are you getting any specific error message?

Please share it if you do.
Chau Trang 9Chau Trang 9
Absolutely.This is the error I got 

URL No Longer Exists
You have attempted to reach a URL that no longer exists on salesforce.com.

You may have reached this page after clicking on a direct link into the application. This direct link might be:
• A bookmark to a particular page, such as a report or view
• A link to a particular page in the Custom Links section of your Home Tab, or a Custom Link
• A link to a particular page in your email templates

If you reached this page through a bookmark, you are probably trying to access something that has moved. Please update your bookmark.

If you reached this page through any of the other direct links listed above, please notify your administrator to update the link.

If you reached this page through a link on our site, please report the broken link directly to our Support Team and we will fix it promptly. Please indicate the page you were on when you clicked the link as well as any other related information. We apologize for the inconvenience.


The error message saying URL no longer exists, that's why I thought I dont have the right component to be called in the script.

Much appreciate your follow up!