Using a SP Widget on Ui16

A while ago Andrew Pishchulin shared a post on Medium where he put a Service Portal widget on UI16. My mind was blown. How did he do it.

His post doesn't go over the specifics but here's what he said;

Service Portal widget can also be used in ServiceNow native UI, all you need to do is just to create a UI Macro/formatter which loads a service portal page with that widget

The way to do this (again thanks to Andrew) is this;

  1. Create an empty Service Portal (I'll name mine "widgetOnly")
  2. Create a Portal Page (I'll name mine "pageForHelloWorld")
  3. Add your widget to the Portal Page
  4. Create a UI Macro (I'll name mine "spHelloWorld") with this code, change height as needed
<?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="widgetOnly?id=pageForHelloWorld" width="100%" scrolling="no" style="border:none;min-height:400px;">
</iframe>
</j:jelly>
  1. Create a UI Formatter with the formatter called "spHelloWorld.xml" and set the table you want.
  2. Add the formatter on the form (same way you'd add a field, via form layout)

Comments

artemis15 commented on May 6, 2020

Instead to creating portal for this, you can alos use $sp.do?id=pag

jacebenson commented on May 6, 2020

That's a great call out. Thanks @artemis15 .

nsierraj commented on May 13, 2020

And you can use "RP.getParameterValue('sys_id');" to pass values to the widget to make it sensitive to the record in the form.

meatsac commented on Nov 1, 2020

This post suggests you can call the widget directly. I haven't had success with this myself but would be interested to hear if this is indeed possible.

https://snhackery.com/2019/04/10/portal-widgets-on-ui-pages/