I have an Apex class OpportunityUpserter
with a static method, where the static method makes a call to another static method in a class called IntegrationUtilities
, as shown below. This gives me a compile error in VC Code Variable does not exist: IntegrationUtilities
. For some reason, the Apex class IntegrationUtilities
is not recognized from insertOpportunities
method. I know that static methods can't access instance variables. But in this case, the static method is trying to access another static method in a different class. What could be the reason for this error?
(All the classes were created using the "SFDX: Create Apex Class" option in SF CLI and all classes have a metadata file.)
public with sharing class OpportunityUpserter {
@Future(callout=true)
public static void upsertOpportunities(Set<Id> opportunityIds, String action) {
Opportunity[] opportunitiesToUpsert = [SELECT Id, name, owner.name, servicenow_sys_id__c FROM Opportunity WHERE Id IN :opportunityIds];
insertOpportunities(opportunitiesToUpsert);
}
public static void insertOpportunities(Opportunity[] opportunitiesToInsert) {
//code to make REST request goes here
sys_id = IntegrationUtilities.getFieldsFromResponse(response, action).get('sys_id');
}
}
public with sharing class IntegrationUtilities {
public static Map<String, String> getFieldsFromResponse(HttpResponse response, String action) {
// more code here
// return Map<String, String>
}
}
OpportunityUpserter
to pinpoint an issue. If it is erroring on deploy, my best guess right now is that it's either an issue of shadowing, or an invisible character that's snuck its way into one of these two classes.IntegrationUtilities
(if you haven't already) and attempt to callIntegrationUtilities.getFieldsFromResponse()
via anonymous apex.IntegrationUtilities
(or both) after adding your code to the shell that was created when you selected "SFDX: Create Apex Class"?