Need to update related records based in a field value from the parent record. If I use with sharing in class, just the records that the current user has access will be updated?


That's correct. You won't be able to query records the user does not have access to, nor will you be able to update records the user has read-only access to. The four main permissions, Create, Read, Update, and Delete (CRUD) are honored when using with sharing, but Field Level Security (FLS) is not honored, so you need to make sure to use Security.stripInaccessible if you want to prevent updating fields the user does not have edit permission on.

  • So if the class has a query that get the related records from that parent record, the records retrieved from that query depends on the user that triggered the class?
    – user87331
    Nov 17 '20 at 12:35
  • @user87331 Yes, depending on the user's sharing for those child records, the query will return just the children they can see.
    – sfdcfox
    Nov 17 '20 at 13:12
  • sfdcfox Thank you for all the help, I really appreciate it.
    – user87331
    Nov 17 '20 at 17:04

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.