3

So I have my global class

global without sharing class PaymentUtils {
    global void refreshFromProvider(id recordId) {
    ...
    }
    
    global Payment_Transaction__c createAndStoreSession(
        decimal amount,
        id paymentId,
        String successURL,
        String cancelURL,
        String currencyISO,
        String customerEmail,
        String storageOption
    ) {
    ...
    }
}

When I instantiate this class, I can use any of the other global methods (not shown), just not the refreshFromProvider method. Does ANYONE have a clue as to why?

utils.createAndStoreSession(20.0, obj.id, '','','','');//works fine
utils.refreshFromProvider(obj.id); //fails with Method is not visible: void namespace.PaymentUtils.refreshFromProvider(Id)

I am tearing my hair out trying to spot what's different. there are other void methods i can use, there are other single input methods that work too!

7
  • I should add, this is in the org where the package is installed. everything else works so there is something special happening here, I just don't know how to refresh or whatever it is that's providing this... odd behaviour.
    – mike
    Nov 30, 2022 at 7:57
  • 1
    I'd repackage triple checking that version of this class that goes into the package has that method...
    – Keith C
    Nov 30, 2022 at 8:33
  • trying to build a new one now (I updated the API version on a bunch of other classes too), Now salesforce decides it's a good time to consider whether or not it wants to make the package available haha! I will report back afterwards!
    – mike
    Nov 30, 2022 at 23:18
  • 1
    @mike - welcome, FYI you can answer your own question (and eventually accept it) to help others. That's the sign something is solved vs. adding it to your question title. Dec 1, 2022 at 21:02
  • 1
    There's an answer, below. Instead of adding "SOLVED" to the title you should mark the answer as best and (if you are permitted, you require reputation to do that) upvote it.
    – Phil W
    Dec 2, 2022 at 8:56

1 Answer 1

3

When a new Apex class is created or it is an existing class and a new package is installed the class takes a dependency on the package version at the time. This dictates what functionality from the managed package the Apex class can see, including global methods.

For example, if the package was a v1.0 that the class was created against and a v1.1 where the new global method was added, then the Apex class can't see that method.

These settings are controlled by the Package Version settings. See also Managing Version Settings for Apex

It will look something like this 10 year old screenshot from my blog enter image description here

You can also see this in the Metadata API for an ApexClass via the packageVersions.

You must log in to answer this question.

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