
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2018 11:24 PM
We are using ServiceNow for IT service management, and we support a number of vessels. We have made an integration so that the lat/lon of the vessels are automatically updated.
Since the vessels travel around the world it would be very helpful if we had a button next to the "Location" field in the Incident window called "Show on map". Clicking this button should open a pop-up with a map and a marker on the location lat/lon.
Looking at the Map pages, I am not sure how to pass a Location to a map page, and how to re-center the map around this location.
Any help with examples would be appreciated. Please note that I am not very adept with scripting so tea-spoon-mode would be appreciated.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2018 05:05 AM
I was searching for UI Policy, when I should have been searching for UI Action. Once Erik Gardner pointed that out, I found this page:
https://www.servicenowguru.com/system-ui/ui-actions-system-ui/open-google-map-location-record/
The Google Maps URL system has since changed, so for a proper lat/lon with zoom I had to try and fail until I ended up with:
mapURL = 'https://www.google.com/maps/place/'+ gr.latitude + ','+ gr.longitude + '/@'+ gr.latitude + ','+ gr.longitude + ',5z';
This made the correct lat/lon marker, centered and zoomed the map to the desired level.
Thank you for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2018 04:11 AM
There is already a module called Critical incident map. You can explore that.
Please Hit ✅Correct, ⭐️Helpful, or ❣️Like depending on the impact of the response

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2018 04:53 AM
Hi Terje,
I'm not sure how to generate a map with only the incident you are coming from but if you can settle on a map with a defined scope/query its much easier.
First you'll have to create a map page and script a query on what you want to show up on the map page. If I understand you correctly you have lat/lon info in your incident ticket which means the map page query script would be against the incident tabel. Ex:
var gr = new GlideRecord("incident");
gr.addEncodedQuery("active=true^cmdb_ciISNOTEMPTY"); //here is you search query
gr.query();
//looping through our query result
while (gr.next()) {
if(gr.<your_lat_field> && gr.<your_lon_field>){
var item = map.addItem(gr);
item.latitude = String(gr.<your_lat_field>);
item.longitude = String(gr.<your_lon_field>);
item.dialog_title = gr.getDisplayValue();
item.icon_width = "32";
item.icon_height = "32";
}
Then you need to create a UI Action on the Incident form which when clicked directs you to the new map page. Preferably in a new tab.
ex an OnClick variant which just redirects you to the map url (which you can get get if you click Try It in the Map record:
action.setRedirectURL (<your_map_url>);
Hope that helps!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2018 05:05 AM
I was searching for UI Policy, when I should have been searching for UI Action. Once Erik Gardner pointed that out, I found this page:
https://www.servicenowguru.com/system-ui/ui-actions-system-ui/open-google-map-location-record/
The Google Maps URL system has since changed, so for a proper lat/lon with zoom I had to try and fail until I ended up with:
mapURL = 'https://www.google.com/maps/place/'+ gr.latitude + ','+ gr.longitude + '/@'+ gr.latitude + ','+ gr.longitude + ',5z';
This made the correct lat/lon marker, centered and zoomed the map to the desired level.
Thank you for your help.