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
yvk431yvk431 

sObject type 'PermissionSet' is not supported

Hi Guys,

 

We have a custom button on a detail page which is used for custom clone and should be acccessible only for user that are assigned with a specific permission set. When I try to achieve this using

var permissionsetid = sforce.connection.query("select id,label from PermissionSet where Label = " + "\'" + "permissionset name" + "\'");

 

The system throwing 

 

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

{faultcode:'sf:INVALID_TYPE', faultstring:'INVALID_TYPE: sObject type 'PermissionSet' is not supported.', detail:{InvalidSObjectFault:{exceptionCode:'INVALID_TYPE', exceptionMessage:'sObject type 'PermissionSet' is not supported.', row:'-1', column:'-1', }, }, }

 

Can anyone let me know that can we achieve this through script, I already thought of a workaround to redirect user to a page from where I can query permissionsets and validate the logged in user.

 

--yvk

 

Best Answer chosen by yvk431
yvk431yvk431
Hi Swastika,

Thanks for the reply, I should have closed this post , I knew we could achieve this by enabling the view and setup configuration. The concern here was that the users were related to multiple business and we dont had any control on displaying the setup menu to the non-admin users

I was able to come up with a solution though, using triggers. When ever the button logic gets executed, I am checking for the same criteria in the trigger and validating the logged in user got the permission sets required.

--yvk

All Answers

sfdcfoxsfdcfox
Check the API version you are querying against (e.g. /soap/ajax/20.0/connection.js is API 20.0). You must use at least version 22.0 in order to query this object.
yvk431yvk431

Hi sfdcfox,

 

This is how I am doing it.

 

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")};
var userid = "{!$User.Id}";
var permissionsetid = sforce.connection.query("select id,label from PermissionSet where Label = \'Channel Manager\'");
var curruser = sforce.connection.query("select id,PermissionSetId from PermissionSetAssignment where AssigneeId =" + "\'" + userid + "\'" +" and PermissionSetId = " + "\'" +permissionsetid + "\'" );

 

 

 

--yvk

Swastika ChatterjeeSwastika Chatterjee
Very old post, but still thought of updating my findings here !

I faced a similar issue. For me the button was not throwing any error for an admin profile user, the error only occured for other non-admin profiles. 
You need to have the "View Setup and Configuration" permission inorder to be able to query Permission Sets. 
This is pointed out in this article --> https://help.salesforce.com/HTViewHelpDoc?id=perm_sets_search.htm&language=en_US 
[*User Permissions needed section]

Once I provided this permission to the non-admin user profile, the error no longer surfaced for that user.

Hope this helps !

-Swastika
Swastika ChatterjeeSwastika Chatterjee
+ To view users that are assigned to a permission set: https://help.salesforce.com/HTViewHelpDoc?id=perm_sets_assigned_users.htm&language=en_US
yvk431yvk431
Hi Swastika,

Thanks for the reply, I should have closed this post , I knew we could achieve this by enabling the view and setup configuration. The concern here was that the users were related to multiple business and we dont had any control on displaying the setup menu to the non-admin users

I was able to come up with a solution though, using triggers. When ever the button logic gets executed, I am checking for the same criteria in the trigger and validating the logged in user got the permission sets required.

--yvk
This was selected as the best answer
SFDC developer55SFDC developer55
Hi yvk,

Did you find any alternate to get this issue fixed in the javascript code?
I would appreciate if you please share your trigger solution here..

Thank you.
Paddy