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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2022 02:42 AM
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);
}
- Labels:
-
Script Debugger
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2022 06:22 AM
Hi,
Can you please complete script of your UI Action and where you have written 2nd part of script?
Not sure where your UI Action is redirecting and where you need sys_id of record.
Thanks,
Anil Lande
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2022 06:32 AM
Sure thing, I have updated the question with a much longer snippet of the code being used.
The UI Action redirects to the appropriate map page and queries the appropriate table using the value set in the map id system property.
I need to find another way to pass this variable without using a system property.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2022 06:51 AM
I believe you have a UI Page with name 'map_page.do' and you are calling page from UI Page.
You can pass additional values in URL as parameter like below:
gs.setRedirect("map_page.do?sysparm_sys_id=sys_id_of_map_page&record_sys_id="+current.sys_id);
And in UI Page HTML part you can get these parameter values like below:
Use RP.getParameterValue("parameterName") to read parameter from URL.
Thanks,
Anil Lande
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2022 07:12 AM