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
marcobmarcob 

PermissionsModifyAllData

Hi,

Is there a way to use the PermissionsModifyAllData field from the Profile object in Apex? I can see in the schema that it is included in the Profile object. However, when i try to use that field, it says that the field name is incorrect, check spelling. It appears to me that all the Permission-fields in the profile don't have the name the schema tells me.

Any suggestions?

Thanks in advance!

Br, Marco

Best Answer chosen by Admin (Salesforce Developers) 
MikeGillMikeGill

That field is not available like this. I say this as you can't include it in a normal formula field. 

 

I think you will need to get the value via a query in your controller. That should work, but I have not tried it myself.

All Answers

MikeGillMikeGill

Just ran this SOQL query and it returned values.

 

select PermissionsModifyAllData from Profile

 

Maybe posting your code would help.

marcobmarcob

Hi Mike,

thanks for your respons, it actually works in Apex. Actually, my initial problem was that it doesn't work in VisualForce pages, but i wasn't clear on that, sorry!

So, i now solved it in the controller, but still wondering why this doesn't work in VF:

    <apex:commandButton value="Delete" action="{!DeleteAll}" rendered="{!$Profile.PermissionsModifyAllData==true}"/>

Profile fields like Name and Description can be referenced in VF, but the permission fields like PermissionsViewDataCategories, PermissionsViewAllData, etc can't be referenced.

Maybe the actual name is different then it shows in the schema?

Br, Marco

 

marcobmarcob

And since we're at it, is there a way to check whether the profile has ModifyAllData rights for a specific object? I can't seem to find an object that holds the relation between Profile and (custom) Object.

Br, Marco.

MikeGillMikeGill

That field is not available like this. I say this as you can't include it in a normal formula field. 

 

I think you will need to get the value via a query in your controller. That should work, but I have not tried it myself.

This was selected as the best answer
marcobmarcob

Ok, i think this confirms my own thoughts, i will stick to apex and not try to solve anything in the VF page.

Many thanks for your help Mike!

Br, Marco