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
benwrigleybenwrigley 

Visualforce and sharing rules

Hi There,

 

I have added a button to an Opportunity page that takes the user directly to a VF Page.

 

I would like to identify if the user has write access to the Opportunity and display an error instead of the VF page if they don't.

 

How have others done this?

 

TIA 

Pradeep_NavatarPradeep_Navatar

You can implement through SOQL Query in controller. Every object has its own share object like opportunityshare object having picklist field OpportunitAccessLevel Read,Read/Write and Owner.

 

Go through the sample code given below :

 

OpportunityShare = [Select o.OpportunityAccessLevel From OpportunityShare o where OpportunityAccessLevel='Read/write'];

 

Hope this helps.