0

I am getting this error when I tried to remove the cacheable=true from the below method.

@AuraEnabled(cacheable=true)
global static boolean packageNotExpired() {
    /// my code;
}

Previously annotated identifier with @AuraEnabled(cacheable=true) must still be annotated: AuraEnabled(cacheable=true)

4
  • If you are working on managed packages and this classes is already added to package, global methods cannot be removed and only deprecated
    – Raul
    Jul 28, 2020 at 14:12
  • 1
    I recommend against the use of deprecation. See this answer for my reasoning.
    – Phil W
    Jul 28, 2020 at 14:16
  • 1
    thanks, @PhilW I visited that post, it is very helpful, after knowing this I would be careful while deprecating any code. Jul 28, 2020 at 14:24
  • Great thanks for the insights @Phil
    – Raul
    Jul 28, 2020 at 14:38

1 Answer 1

2

I note it is global and removing cacheable from the global method would impact subscriber code - that code may be using this via a wire, which requires the result to be cacheable. (I am assuming you have this code in a managed package of some form, hence the use of "global".)

I suggest you add a separate uncached method that invokes the same processing as the cacheable one. The second method can even directly call the first one since the cacheable annotation only impacts client communications:

@AuraEnabled(cacheable=true)
global static boolean packageNotExpired() {
    /// my code;
}

@AuraEnabled
public static Boolean packageIsNotExpired() {
    return ThisClass.packageNotExpired();
}

It is worth noting that the use of global access modifier should always be minimized.

You must log in to answer this question.

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