How to Enable Geolocation Tracking for Health & Safety Incidents in ServiceNow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi Team,
We have a requirement to enable geolocation tracking for Health & Safety incidents in ServiceNow. The goal is to capture the user’s location automatically when an incident is created (especially from mobile).
Has anyone implemented a similar requirement?
- Which plugins need to be activated?
- How do we configure geolocation fields on the Incident form?
- Is there a way to achieve this in Now Mobile using action-based tracking?
- If the Mobile Location Tracking plugin is not available in PDI, what’s the best alternative?
Any guidance, steps, or examples would be greatly appreciated!
Regards,
Pasha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
you can try to use native javascript API to see if it picks latitude and longitude of the browser user is currently using
-> create 2 variables of type string to store latitude and longitude and hide it always using UI policy
-> create onLoad catalog client script which sets this hidden variable from portal while user submits
-> then use record producer script to store those in target field names from those variables
Note: users will have to allow location access from browser settings then only this works
It worked for me
function onLoad() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
function(position) {
var lat = position.coords.latitude;
var lng = position.coords.longitude;
// Set values in form variables (adjust variables names)
// g_form.setValue('u_latitude', lat);
// g_form.setValue('u_longitude', lng);
g_form.addInfoMessage('Location captured: Lat ' + lat + ', Lng ' + lng);
},
function(error) {
g_form.addErrorMessage('Geolocation failed: ' + error.message + '. Enable location services.');
}, {
timeout: 10000,
enableHighAccuracy: true
}
);
} else {
g_form.addErrorMessage('Browser does not support geolocation.');
}
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago - last edited a week ago
Hi Ankur,
Thanks for proposing the solution it’s working for me as well.
I’m trying to implement something slightly different:
On my Incident form, I have a Location field (referencing cmn_location).
Based on the selected Location, I need to automatically display the User’s Location.
Essentially:
User selects a Location (from cmn_location)
Another field should show the location of the user (caller) or the related user-location field
This functionality we need in NowMobile.
If you could guide me on how to populate the user location when the Location field changes, that would be very helpful.
Thanks!
