2

in SF i created an sObject with custom fields. All users with admin permission can see all fields of this sObject. The user with the profile "Custom: Marketing Profile" should only see a few fields of this sObject but not all!

For this, i activated Field Level Security.

Security Controls > Field Accessibility > sObject > View by Fields > Select special Field > change Field Access to Hidden

If i logged in as an Custom: Marketing Profile user, i not see the Field in SF. As a admin i will see all fields.

Now i created an Lightning Component App and will show the field for the special users.

Unfortunately in LC my Custom: Marketing Profile will see all field of my sObject but i set the field access to hidden?! Why the Field Accessibilty not work in Lightning Component.

What should i do that LC only show the Fields which i selected in Field Accessibilty?

2

As per Standard Salesforce docs:

Lightning components don’t automatically enforce CRUD and FLS when you reference objects or retrieve the objects from an Apex controller. This means that the framework continues to display records and fields for which users don’t have CRUD access and FLS visibility.

You must manually enforce CRUD and FLS in your Apex controllers. For example, including the with sharing keyword in an Apex controller ensures that users see only the records they have access to in a Lightning component. Additionally, you must explicitly check for isAccessible(), isCreateable(), isDeletable(), and isUpdateable() prior to performing operations on records or objects.

So you need to set it manually. You can find more details here

0

The below stack exchange link might be helpful to you. How to use fieldsets with Lightning?

1.Create a fieldset 2.on the profile mark the field properties hidden/read/write the way you want 3.query the information of fieldset using an apexclass and from schema object get field properties and pass it to the lightning component. 4. In the lightning component use aura if tag to only render the tag if its editable for any field.

Hope this helps.

This generic class can also be used for other components and object fields making it a generic and re-usable class.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.