Google Maps - Business Rule to Populate Latitude & Longitude is not working

Jenny17
Tera Contributor

Has anyone recently enabled the Google Maps Plugin?  We recently obtained an API Key from Google, turned on the Business Rule: get_lat_long & activated the Scheduled Job: Process Geocoding Request. 

The Business Rule is not populating the lat & long in our Location table.  

We found an older article in the Community (see link below) and tried the script in the article, it did not work either. 

https://community.servicenow.com/community?id=community_question&sys_id=71a30f65dbd8dbc01dcaf3231f96...

Does anyone who has recently enabled Google Maps have any tips they can share?

10 REPLIES 10

JennyHu
Tera Guru
Tera Guru

Can you try manually running the Scheduled Job, and check the System logs for any errors?

Jenny17
Tera Contributor

Has anyone recently enabled Google Maps and had success with the out-of-the box Business Rules?

Are you getting any errors in the logs? In your google api dashboard, are you seeing anything trying to make requests? Did you set your api key anywhere in servicenow?

We have not gotten any errors in the logs.  And the API Dashboard does show activity.  The only place we set the API key was in the Google Maps config page.  

 

We are not using the field 'street' instead we are using two fields u_address and u_address2.  The second field u_address2 mainly stores suite # and appt #.  

I've replace   var street = new String(current.street);  with

var street = newString(current.u_address);  

and the script still did not work.  

Out of the box script:

if (current != null) {
var street = new String(current.street);
street = street.replaceAll("\r","");
street = street.replaceAll("\n"," ");
var address = encodeParm(street) + " " + encodeParm(current.city) + " " + encodeParm(current.state) + " " +
encodeParm(current.zip) + " " + encodeParm(current.country);
address = address.trim();

if (address.length > 0) {
var point=GoogleMapsHelper.google_queueRequest(address, current);
}
}

// encodes non-Latin characters
function encodeParm(parm) {
return GlideStringUtil.urlEncode(parm);
}