Passing a record's sys_id when navigating to a Map Page upon clicking a UI Action

Jack Hoblyn
Tera Contributor

I have created a UI action which plots a records coordinates on a map page using a marker.

I am trying to pass the sys_id of the form view of the record I am on to the map page so that it displays that particular record's coordinates on a map.

Currently, I am overwriting a system property every time the button is clicked with the sys_id of the current record.

I am then pulling out that value and adding it to a query

Is there a better way of doing this? If so what is the best practice? I imagine adding the sys_id to the URL would be a good idea but I'm not sure how best to go about it.

- - - - - - - 
//Set map id system property with sys_id of the current record

var gr = new GlideRecord("sys_properties");
gr.get("sys_id_of_map_id_system_property");
gr.setValue("value", current.sys_id);
gr.update();

// redirect to map

gs.setRedirect("map_page.do?sysparm_sys_id=sys_id_of_map_page");

- - - - - - - 
//Get the sys_id of the record from the map id system property

var myparm = gs.getProperty("map.id");
var gr = new GlideRecord("table");
gr.addQuery('sys_id', myparm);
gr.query();

//add the coordinate sto the map page as a marker

while (gr.next()) {
if (gr.location.latitude && gr.location.longitude) {
var item = map.addItem(gr);
}
7 REPLIES 7

Hi Anil, just adding on to my question from yesterday.

It appears that the UI page being used is indeed 'mapping assist'.

Adding in the code snippet as you have done not only seems to throw errors in the UI page but also doesn't help with the requirement of passing the sys_id to the map page itself. The idea here is to load in the coordinates from the specified record that has been clicked, onto the relevant map page so that a map is displayed with a pointer.

 

Hi Anil, just adding on to my question from yesterday.

It appears that the UI page being used is indeed 'mapping assist'.

Adding in the code snippet as you have done not only seems to throw errors in the UI page but also doesn't help with the requirement of passing the sys_id to the map page itself. The idea here is to load in the coordinates from the specified record that has been clicked, onto the relevant map page so that a map is displayed with a pointer.

Inactive_Use851
Kilo Contributor

Jack - Did you get anywhere with this?