Salesforce Certified Platform Sharing and Visibility Architect Practice Questions

Salesforce Certified Platform Sharing and Visibility Architect exam preparation

Salesforce Certified Platform Sharing and Visibility Architect practice questions in English: 180 questions with explanations. The mock exam has 60 questions and 120 minutes.

Salesforce Certified Platform Sharing and Visibility Architect free question 10 / 10 · Domain 4: Implications of Security Model Choice

A test method verifies a sharing model. The code enters a System.runAs block for user u2 and, inside it, a nested System.runAs block for user u3. As whom does the code that follows the inner block, still inside the outer block, run, according to the example in the Apex Developer Guide (Winter ’23)?

  1. In the original system context, because the inner block has ended
  2. As u3, the user of the inner runAs block, which stays in effect
  3. Nesting is not allowed, so the inner block causes an error when the test is saved
  4. As u2, the user specified for the outer runAs block
Show the answer and explanation

Answer: D

Why this is correct
The guide says you can nest more than one runAs method, and its example places a block for u3 inside a block for u2. The comments in the example show that code in the outer block runs as u2 and code in the inner block runs as u3, and that any additional code after the inner block would run as u2. Inside a runAs block, the user’s record sharing is enforced, so each part of the test sees records as that user would.

Why the other options are wrong
"As u3, the user of the inner runAs block, which stays in effect" … The u3 context applies only inside the inner block. The comment in the guide’s example says that any additional code after it runs as u2.
"In the original system context, because the inner block has ended" … The guide says the original system context starts again after all runAs test methods complete. Code that is still inside the outer block is in the u2 context.
"Nesting is not allowed, so the inner block causes an error when the test is saved" … The guide states that you can nest more than one runAs method and gives an example with a u3 block inside a u2 block.

More on runAs
The guide adds that the user’s sharing permissions are enforced within a runAs block regardless of the sharing mode of the test class, and that if a user-defined method is called inside the block, the sharing mode enforced is that of the class where the method is defined. The runAs method ignores user license limits, and every call to runAs counts against the total number of DML statements issued in the process.

Go to the Salesforce Certified Platform Sharing and Visibility Architect practice app (10 free questions; purchase unlocks all questions)

See the full practice set