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
Christine KleinChristine Klein 

Apex code to restrict submission based on a permission set

Is there a way to pull in permission sets into an apex class? We are looking to restrict the ability for users to click on the submit to finance button (custom JS button on the opportunity page layout).  Creating a new profile and page layout isn't an option for a solution, so I was wondering if there was a way to prevent a user from clicking on this button if they do not belong to a specific permission set.  For example, only our Order Admin team can submit opportunities to Finance - these folks have their own permission set called Order Admins.
Thanks for your help!

Best Answer chosen by Christine Klein
willardwillard
If the opportunity page is a VF page, you can put a method in your controller called: getIsOrderAdmin()
You can use the results of that in your hiding of the javascript button
<pre>
<script>
// hope you're already using jQuery.  If not - why not???
$j = jQuery.noConflict();
if (!{!isOrderAdmin}) {
    $j("#submitOppToFinance").hide();
}
</script>
</pre>