How to get the error on clicking on new button on account if user doesnt hv permission of creating.?
Hi,
I have a "New Account" button on Account object.
this new Account button redirects to another visualforce page.
Now, i want When a user clicks the "New Account" button on the Account Page Layout and they do not have the "Create" permission on their user profile or granted through permission sets, the following error message is displayed: "You have insufficient privileges to create Accounts".
but i need to check the create permission of user as soon as i click the "NEW ACCOUNT" button and throw an error if he doesn't hv access to the account creation....may b we need to write a class and then call that class on click of button.
but there are lots of profiles ....so will it be a good solution to go in each profile and do the changes....coz in some of the cases we have given permission through PERMISSION SET.
Try using "With Sharing" in the controller of corresponding VF page.
Thanks
Hi,
Since when user click 'New Button' it will navigate to VF page right.
Then u can do 2 ways.
1.In profile goto down and find out 'Enabled Apex Classes Access' remove the controller or extension of that VF page in that.
2. create one custom button on Account and do some validation onit and if it ok then navigate to that VF page.
Regards,
Rajesh.
thanks for your reply!!!
but i need to check the create permission of user as soon as i click the "NEW ACCOUNT" button and throw an error if he doesn't hv access to the account creation....may b we need to write a class and then call that class on click of button.
** NEW ACCOUNT is a custom button.
Hi,
When u click on that button u just override to VF page.
And try it as with 1 option it will throw an error insufficient priviligers.
Regards,
Rajesh.
HI,
Then go like this,
if (Schema.sObjectType.Contact.fields.Email.isCreateable()) {
// Create new contact
}
Regards,
Rajesh.
Hi,
Not sure. Try to write in custom button and validate it. else as u told try for class.
Regards,
Rajesh.