Activity Forums Salesforce® Discussions What is the purpose of system.runAs() in Salesforce?

  • Kirandeep

    Member
    July 1, 2020 at 12:21 pm

    System method runAs enables you to write test methods that change the user context to an existing user or a new user so that the user’s record sharing is enforced. The runAs method doesn’t enforce user permissions or field-level permissions, only record sharing.

  • Ayush

    Member
    July 1, 2020 at 1:20 pm

    Normally, all Apex codes run in System mode, and therefore the current user’s various permissions and record sharing rules are not taken into consideration. The system method, System.runAs(),lets us write test methods that change user contexts to either an existing user or a new user. All of that user’s record sharing is then enforced. You can only use runAs in a test method. But runAs() does not validate CRUD or Field Level Security permissions.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos