Reputation: 11
I have problem using maps.API.Geocode in salesforce. The idea is to run a method via 'Process Builder', getting the longitude and latitude for a list of addresses. I assume that the callout may take a while, so I think I should use the @future (callout = true)
annotation. When I run the 'poc' getGeocode() method:
public class GeocodeService {
@InvocableMethod
public static void getGeocode() {
geocode();
}
public static void geocode() {
Map <String, String> options = new Map <String, String> {'version' => '1', 'address' => '415 Mission Street, San Francisco, CA 94105 USA'};
Map<String, object> result;
result = (Map<String, object>) maps.API.Geocode(options);
System.debug(result);
}
}
Everything works as it should. But when I add @future (callout = true)
to geocode() method and run it again, I get this message
| FATAL_ERROR | System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out
I run the method from the console, I don't do any DML before, where should I look for the cause of the problem?
Upvotes: 1
Views: 427