I've encountered a problem. I'm writing code in our developer org where we have a managed package installed (this package is ours as well). I'm trying to call a method of an apex class defined in that installed package, but when deploying, a "method is not visible" error is thrown.
global void execute(Database.BatchableContext BC, List<ERPvs__Comprobante_Punto_De_Venta__c> scope){
for(ERPvs__Comprobante_Punto_De_Venta__c cpv : scope){
try{
if(cpv.ERPvs__Empresa__r.ERPvs__Empresa_UY__c){
ERPvs.FacturacionElectronicaController.generarPDFCPVUY(cpv.Id);
}else{
ERPvs.FacturacionElectronicaController.generarPDFCPV(cpv.Id);
}
}catch(Exception e){
body += 'LN' + e.getLineNumber() + '-' +cpv.Id + '-' + cpv.Name + ' - Error en PDF: ' + e.getMessage() + '\n';
}
}
}
As you can see, I am calling two methods there. The method in the else block was already being called before with no problem, and I'm trying to add the call to the first method, that is the one that is throwing the not visible error.
The thing is, both methods are declared the same way in the "FacturacionElectronicaController" class in the managed package:
WebService static String[] generarPDFCPV(String cpvId){
String[] result = new String[2];
result[0] = '1';
ApexLogger.Debug(LoggingLevel.WARN,'>> cpvId: '+cpvId);
try{
doGenerarPDFCPV(cpvId);
}catch(Exception e){
result[0] = '0';
result[1] = e.getMessage() + ' - Línea ' + e.getLineNumber() + ': ' + e.getStackTraceString();
}
return result;
}
WebService static String[] generarPDFCPVUY(String cpvId){
String[] result = new String[2];
result[0] = '1';
ApexLogger.Debug(LoggingLevel.WARN,'>> cpvId: '+cpvId);
try{
doGenerarPDFCPVUY(cpvId);
}catch(Exception e){
result[0] = '0';
result[1] = e.getMessage() + ' - Línea ' + e.getLineNumber() + ': ' + e.getStackTraceString();
}
return result;
}
(Both methods being called there are declared as public so it should work)
As per the documentation:
Methods defined with the webservice keyword are inherently global. Any Apex code that has access to the class can use these methods. You can consider the webservice keyword as a type of access modifier that enables more access than global.
So why is the compiler throwing not visible? Am I missing something?
EDIT: I've researched a little further, and found something about version settings for the apex classes, maybe it has something to do about this? The thing is I looked for the managed package class to see the signatures of the methods available and the one I'm trying to access is there: