- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2024 09:12 PM
Hi Team,
I have created a map page to track Assigned To's location. How can I attach it to sn_customerservice_task form?
Regards,
Amit
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2024 09:28 AM
Hi @Amit83
As a workaround, would recommend you to create a UI Action with following script-
var latSource = g_form.getValue('u_fe_last_latitude');
var longSource = g_form.getValue('u_fe_last_longitude');
var latDest = g_form.getValue('latitude');
var longDest = g_form.getValue('longitude');
var mapsUrl = 'https://www.google.com/maps/dir/?api=1&origin=' + latSource + ',' + longSource + '&destination=' + latDest + ',' + longDest + '&travelmode=driving';
g_navigation.openPopup(mapsUrl);
This will open the Google Maps in a new window showing the route, eta and source and destination.
Please mark my answer helpful and correct.
Regards,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2024 02:18 AM
Hi @Amit83
Need to create a new modules available in CSM_task table and in link type
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 08:31 AM
But how can I embed it to case task form? Also, if you could help me with any other alternatives for displaying map on case task form will work for me. I am using following map page script which is working fine-
var now_GR = new GlideRecord("sn_customerservice_task");
//now_GR.addQuery('sys_id', '3e8****833100');
now_GR.query();
while (now_GR.next()) {
var item = map.addItem(now_GR);
item.latitude = now_GR.u_parent.location.latitude.getDisplayValue(); // Latitude of the destination
item.longitude = now_GR.u_parent.location.longitude.getDisplayValue(); // Longitude of destination
item.icon = "http://maps.google.com/mapfiles/kml/pal3/icon51.png";
item.icon_width = "32";
item.icon_height = "32";
var secondLocationItem = map.addItem(now_GR);
secondLocationItem.latitude = now_GR.u_fe_last_latitude.getDisplayValue('u_fe_last_latitude'); // Latitude of the source location
secondLocationItem.longitude = now_GR.u_fe_last_longitude.getDisplayValue('u_fe_last_longitude'); // Longitude of the source location
secondLocationItem.icon = "http://maps.google.com/mapfiles/kml/pal3/icon32.png"; // Different icon for the second location
secondLocationItem.icon_width = "32";
secondLocationItem.icon_height = "32";
// Draw a line connecting the two locations
map.addLine(item, secondLocationItem);
// Call Google Maps Directions API to get route information
var directionsURL = "https://maps.googleapis.com/maps/api/directions/json" +
"?origin=" + item.latitude + "," + item.longitude +
"&destination=" + secondLocationItem.latitude + "," + secondLocationItem.longitude +
"&key=AIzaSy*****dgO3fxwbd3UU"; // Replace YOUR_API_KEY with your actual Google Maps API key
var response = new GlideHTTPRequest(directionsURL).get();
var responseBody = response.getBody();
var parsedResponse = new global.JSON().decode(responseBody);
if (parsedResponse && parsedResponse.routes && parsedResponse.routes.length > 0) {
var route = parsedResponse.routes[0];
if (route && route.legs && route.legs.length > 0) {
var leg = route.legs[0];
var etaSeconds = leg.duration.value; // Duration in seconds
var etaMinutes = Math.round(etaSeconds / 60); // Convert to minutes
gs.info("Estimated Time of Arrival: " + etaMinutes + " minutes");
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 09:26 AM
Dear @Amit83
code is week area for me mate, what i know i shared mate.
@AshishKM any help.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 03:45 AM - edited 03-06-2024 03:49 AM
You cannot put Map page on case task form. Also, this is not possible in ServiceNow. I recommend either exploring the Field Service Management plugin or integration with 3rd party vendors.
Service-now Consultant