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
Felicia Abramson - Bit9Felicia Abramson - Bit9 

Error Message on Apex Based Buttons

We have some buttons we want to put on every page layout (since that is the only reason why we have different page layouts on this one object), and the buttons are driven with Apex. The plan is to only allow users in certain profiles or with certain permission sets to click the buttons successfully. Right now when a user clicks the button and doesn't have the Apex class enabled for them, they recieve an ugly error message:

User-added image


Is there any way we could customize this to show an error message like "Your account is not enabled for this functionality. Please contact the SFDC admins"?
Andy BoettcherAndy Boettcher
You can use the {!User.Profile} field in your Javascript to help give a more graceful error - read up on another example here:  http://salesforce.stackexchange.com/questions/28886/using-user-profile-merge-field-in-javascript-if-statement