Enforce Access Modifiers on Apex Properties in Lightning Component Markup (Critical Update, Postponed)

This critical update is postponed to Summer ’21. It was scheduled for auto-activation in Summer ’20. This critical update makes Lightning components consistent with the use of Apex properties in other contexts. For example, a markup expression can no longer access an Apex property with a private Apex getter. This critical update was first made available in Winter ’20.

Where: This change applies to Aura and Lightning web components in Lightning Experience, Salesforce Classic, Lightning communities, and all versions of the Salesforce app.

When: This critical update is enforced when a sandbox or production org is upgraded to Summer ’21. Enforcement starts on April 4, 2021 and takes effect when your instance is upgraded to Summer ’21. To find the exact activation date for your instance, refer to https://status.salesforce.com.

Why: Let’s look at an example for an Apex class with a private getter for a counter class property.

public class EnforcePrivateGetter {

    public Integer counter { private get; set; }

    public static EnforcePrivateGetter GetRepro2()
        EnforcePrivateGetter result = new EnforcePrivateGetter();
        result.counter = 2; 
        return result;

With the critical update enabled, this Aura component can’t access the private getter with the {!v.apexObject.counter} expression. The same restriction applies for a Lightning web component.

<aura:component controller="EnforcePrivateGetter" access="global">
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

    <aura:attribute type="EnforcePrivateGetter" name="apexObject" />

    counter = {!v.apexObject.counter} <br></br>

Here’s the JavaScript controller.

    doInit : function(cmp, ev) {
        var action = cmp.get("c.GetRepro2");
        action.setCallback(this, function(response) {
          var state = response.getState();
          if (state === "SUCCESS") {
            cmp.set('v.apexObject', response.getReturnValue());
          else if (state === "ERROR") {
            console.log('Error : ' + JSON.stringify(errors));

With the critical update enabled, the fix is to remove the private access modifier on the getter and change the class variable definition to:

public Integer counter { get; set; }

To make an Apex property readable outside the Apex class, the property can’t have a private or protected access modifier.

How: To test this critical update, we recommend working in a sandbox to complete testing before the initial enforcement date of April 4, 2021, which is the Auto-Activation Date in the UI. After April 4, you can no longer activate or deactivate the critical update and you can test behavior only in a sandbox that's already been upgraded to Summer ’21. If you don't activate the critical update before April 4, it will be automatically activated when your instance is upgraded to Summer ’21.

  1. From Setup, enter Critical Updates in the Quick Find box.
  2. Select Critical Updates.
  3. Review the details for the “Enforce Access Modifiers on Apex Properties in Lightning Component Markup” critical update.
  4. Click Activate.
  5. Test the behavior of components that use Apex classes with private or protected access modifiers on getters.