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
QueplixQueplix 

Security Profile to Objects permissions retrieval

Hi All,

 

How can I programmatically retrive which standard and custom objects a given security profile has access to?

Also how to retrieve field level permissions?

 

Thanks

 

SuperfellSuperfell
describeSObject contains all this information however it doesn't allow for getting it for an arbitrary profile, just the current users profile.
Rajesh ShahRajesh Shah
I have another question to it.
For a particular record of a Object, do we have any calls to check if the current user has Read, Edit or Delete access to it?
pierpipierpi
Hi,
I have the same requirement: determining the access permission (privileges) of the current user on a record of a given type (this may be affected by sharing rules, the user may have delete permission on the object but not on a specific record).

Any idea anyone?

Thanks
Pierpaolo
Rajesh ShahRajesh Shah

We found that there is no method which can determine the access permission of the current user on a record. But there is a alternative solution. We created an apex class with sharing which has a method. That method takes in the record, makes a update call and then rollbacks the transaction. If during the update, any exception occurs, catch it and see if it of the type restricitng the user saying no permission. If yes, then it means user does not has the permission. Also since we will rollback, no actual update will happen in the database.

Hope it is clear.

 

pierpipierpi
Hi Rajesh,
The explanation is clear, very helpful and it will do for me.  It would be nice if there was a built in mechanism to do it.

Thanks
Pierpaolo
TusharDodiaTusharDodia

@rajesh shah sir...

I think,

We Can check d permission for current user with the help of describeSobject result.

DescribeSoblectResult.Iscreatable();

isdeletable. etc

We jst cant check access rights of another user.

 

thanks

Tushar dodia