You need to sign in to do that
Don't have an account?
Hemant Reddy
Click on any action button should validate whether user has read/write or read access
We have multiple action buttons (images) on a page based on formula fields . Click on any action button should check whether the current user has edit access to the record . If current user has read only access, display error message, otherwise proceed with existing action button functioanlity . There are several action buttons in a page and same logic should be applied for all . What is the best way to implement this ?
SELECT RecordId, HasEditAccess FROM UserRecordAccess WHERE UserId = [single ID] AND RecordId = [single ID]
All Answers
Implement a intermediate page & Controller with below functionality
Click on any action button in page, redirect to the intermediate page & controler. Intermediate page / controller checks whether user has read or read/write access by querying Share object .
1. If user has read only access, display message "You are not authorized to perform the op" and back to the record
2. If user has read/write access, redirect to the correct action button URL, which is captured in intermediate page .
SELECT RecordId, HasEditAccess FROM UserRecordAccess WHERE UserId = [single ID] AND RecordId = [single ID]
If we define a variable and set the variable value to true or false based on access on page load , will that variable be accessible for all classes .
In my scenarion, each action button on page goes through separate flow ( apex page and apex classes)
For e.g : Page has below buttons .
submit1 button and on click it calls submitPage1 and submitClass1 apex class
submit2 button and on click it calls submitPage2 and submitClass2 apex class
submit3 button and on click it calls submitPage3 and submitClass3 apex class
As I mentioned, user can click submit1 or submit2 or submit3 buttons and they have independent pages and classes