[SalesForce] Must Lightning Data Service always respect running user’s object/field access

For simple component work, I prefer to use Lightning Data Service as opposed to @AuraEnabled Apex.

And while I have not seen this documented, it appears that the Lightning Data Service always respects running user's object/field access.

In most cases this is great. In other cases I wish I could toggle this behavior ala "with sharing" keyword in Apex.

Has anyone seen formal documentation that confirms the Lightning Data Service always respects user's object/field access levels and cannot be toggled? Is there a way around this?

Best Answer

The developer docs do indeed say that FLS/sharing is respected by Data Service:

Use Lightning Data Service to load, create, edit, or delete a record in your component without requiring Apex code. Lightning Data Service handles sharing rules and field-level security for you. In addition to not needing Apex, Lightning Data Service improves performance and user interface consistency.

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/data_service.htm

I don't believe that you can make it ignore FLS/Sharing. So you would have to write your own Apex controller for that. Or, even better, roll your own custom component which encapsulates data access and works like Data Service, just without the security part.

Related Topic