Activity Forums Salesforce® Discussions How to ensure FLS while working with Lightning Component?

  • madhulika shah

    Member
    September 13, 2018 at 1:43 pm

    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.

    Thanks.

  • Avnish Yadav

    Member
    September 13, 2018 at 1:47 pm

    Hello Prachi,

    FLS is ensured by manually or by lightning Data Service.

    Thanks.

  • shariq

    Member
    September 13, 2018 at 3:02 pm

    Hi,

    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 6 years, 2 months ago by  shariq.
  • Parul

    Member
    September 13, 2018 at 3:50 pm

    Hi.

    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.

     

    Thanks

Log In to reply.

Popular Salesforce Blogs