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
Prabhat Singh 56Prabhat Singh 56 

Is there a way to regulate access to this method?

hello Team,

 Is there a way to regulate access to this method? Like a permission in a profile or permission set? Or only give a specific user access to this method? 

Thanks
Gareth Jones 7Gareth Jones 7
One option could be to place your method within an if-statement. The 'true case' would be that the user has the necessary permission set, determined using a SOQL query:

List<PermissionSetAssignment> permSetAssList = [SELECT PermissionSetId FROM PermissionSetAssignment WHERE AssigneeId= :UserInfo.getUserId() AND PermissionSet.Name = 'EntityFasadUser'];
if (permSetAssList.size() > 0) {
    callTheMethod()
}