• #33922
     Prachi #9

    How to ensure FLS while working with Lightning Component?

    How to ensure FLS while working with Lightning Component?


    Hi Prachi,

    FLS and CRUD are not automatically enforced in the lightning component whenever any object is referenced in the Apex Controller and the component will display the fields and records for which the users do not have access. Therefore we should manually enforce the FLS and CRUD in the Apex Controller, or we should try to use Lightning Data service wherever possible because it takes care of FLS and CRUD for us.



    Hello Prachi,

    FLS is ensured by manually or by lightning Data Service.


    Salesforce | shariq shariq #1


    FLS stands for field level security. FLS can be ensure by adding permission checks before performing DML.
    Suppose we are performing DML on account object and we want to ensure FLS for name field then :

    For an upsert DML
    Account acc = new Account();

    if(Schema.sObjectType.account.fields.name.isCreateable() && Schema.sObjectType.account.fields.name.isUpdateable()){
    acc.name = ‘Test’;

    here it checks weather user has permission to update and create name field or not. this is how it is ensuring the FLS. similarly we can add checks for some other DML’s.

    Hope this helps!

    • This reply was modified 5 months, 1 week ago by Salesforce | shariq shariq.
    Salesforce | Parul Parul #2


    Lightning Data Services already ensures Field Level Security and we can also use the Apex using isAccessible, isCreateable, isDeleteable, isCreateable and etc methods of Schema class.



Viewing 5 posts - 1 through 5 (of 5 total)

Please to reply to this topic.


We're not around right now. But you can send us an email and we'll get back to you, asap.


About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2019 Forcetalks. All Right Reserved.

Log in with your credentials


Forgot your details?