Best way to extract a sys_id from a URL on a map page?

Jack Hoblyn
Tera Contributor

I have a UI action which redirects to a map page to display a location's coordinates.

I wish to display the coordinates of the particular location from a UI Action on it's form view.

I can pass the locations sys_id in the redirected URL but wish to extract that to use it but the bellow code is not working.

 

// redirect to map page with sys_id
gs.setRedirect("map_page.do?sysparm_sys_id=b0395f572fe341101aa7ff1df699b645&sysparm_location=" + current.sys_id);

- - - - - - - 

//Display map with coordinates

var myparm = gs.action.getGlideURI().getMap().get("sysparm_location");

gs.info("sys_id1= " + myparm);

//Grab this incident record from the sys_id
var gr = new GlideRecord("locations");
gr.addQuery('sys_id', myparm);
gr.addActiveQuery();
gr.query();

 

3 REPLIES 3

Saiganeshraja
Kilo Sage
Kilo Sage

Assuming :

In the myparm you are not getting the sys_id of the incident . Make sure to get the incident sys_id.

Check that once.

 

Mark correct and helpful, if it helps

Shamma Negi
Kilo Sage
Kilo Sage
Same thing i had to do but couldn't find much on map pages. Hence i did this by copying the sysid in user preference and from there i passed it to map page. Hope this helps
Regards,Shamma Negi

For anyone interested, the solution was to set the sys_id to a session variable and to get it from the Map Page as follows.

 

UI Action

var session = gs.getSession();
session.putClientData('sys_id', current.sys_id);

 

Map Page

var session = gs.getSession();
var myparm = session.getClientData('sys_id');