Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Passing current record sys_id to widget in UI16

Ashley
Kilo Sage

Good Evening,

 

I have a challenge for everyone, I am currently building a scoped application within ServiceNow, a widget is being placed on the incident form which will dynamically change based on the record being viewed.

 

I am using a UI Macro and UI Formatter to display the widget on the incident form, the final piece of the puzzle is to be able to grab the record sys_id and pass this to the widget to grab the required data.

 

UI Macro:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
	<iframe src="/$sp?id=checklistwidget" width="100%" scrolling="no" style="border:none;min-height:400px;"></iframe>
	<script>
		var sysid = ${sys_id}
	</script>
</j:jelly>

I can get the sys_id to display on the form, in the widget I tried using gs.getParameter() but I think as this is a scoped application I don't seem to have access to the url.

 

I also tried to use gs.action.getGlideURI().toString(); but this doesn't return anything either.

 

Any ideas?

 

Kind Regards

Ashley

 

1 ACCEPTED SOLUTION

Ashley
Kilo Sage

Managed to resolve this with using:

var gURI = new GlideURI(); //for Scoped Applications
var sysid = gURI.get('sys_id');
gs.info(sysid);

Further info:

https://docs.servicenow.com/bundle/tokyo-application-development/page/app-store/dev_portal/API_refer...

 

Kind Regards

Ashley

View solution in original post

1 REPLY 1

Ashley
Kilo Sage

Managed to resolve this with using:

var gURI = new GlideURI(); //for Scoped Applications
var sysid = gURI.get('sys_id');
gs.info(sysid);

Further info:

https://docs.servicenow.com/bundle/tokyo-application-development/page/app-store/dev_portal/API_refer...

 

Kind Regards

Ashley