4

In the Salesforce Summer '22 Release Notes, there is a small section on the new scope annotation for @AuroEnabled Apex methods:

Under what conditions would you not want to adopt this annotation? When is enabling global scope not the appropriate thing to do?

Example from the dreamhouse-lwc sample application:

public with sharing class PropertyController {
  @AuraEnabled(cacheable=true scope='global')
  public static PagedResult getPagedPropertyList(String searchKey...) {
    // snip...
  }
}

1 Answer 1

2

Not sure, if this information was available at the time of asking, but today you can find the answer here.

What it means:

As long as we don't write Apex used in Lightning components used in LWR, the global scope doesn't make a difference. I'd opt for the more restrictive and don't use it.

If Apex is called by a component from a LWR context and Salesforce's CDN is used, for speed reasons it's worth asking, if the data is to be publicly available and doesn't get stale. In that specific case declaring a global scope can make sense.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .