UI Page and Widget in Scoped App.

brianc
Kilo Contributor

Hi All,

I've created a small scoped app that has a widget and UI page.   When Adding the widget to my homepage I get the following error:


GlideForm is not allowed in scoped applications


The render function of the widget contains the following code based on code from the wiki (Creating a Custom Homepage Widget - ServiceNow Wiki)

I have modified the code by pre-pending 'global' to the renderer object

2015-03-25 16_36_10-ServiceNow.png

If GlideForm is not allowed in scoped applications, how does one create a custom widget for inclusion in their app?   I played around with various things, like adding the global namespace in front of the GlideForm, and various other things.

The widget gets added to the homepage, but only 'null' is displayed in the content section.   See image:

2015-03-25 16_34_58-ServiceNow.png

Thanks in advance for any help that can be provided.

Brian.

1 ACCEPTED SOLUTION

tltoulson
Kilo Sage

Hi Brian and Paul,



I have figured this out if you are still interested and haven't figured it out on your own yet.   There have actually been a few changes it seems to the API for widgets.   GlideForm is no longer needed directly and the renderer's interface has changed.



Now you need only two things:



renderer.getPreference(<preference name>) => replaces renderer.getPreferences().get(<preference name>)


renderer.getRenderedPage(<ui page name>) => replaces GlideForm, setDirect, setRenderProperties, etc



So your render script should now look like:



function render() {


      var name = renderer.getPreference('name');


      return renderer.getRenderedPage(name);


}



Dynafrom Wang, you may be interested in this as well given your Hackathon Bootstrap CMS.   This can help you get it out of the global scope


View solution in original post

10 REPLIES 10

Vaughn Romero
ServiceNow Employee
ServiceNow Employee

I have updated the wiki to include code samples for scoped applications for both Widgets and Gauges. Thanks to Travis Toulson and Stephen Farrar for supplying the new renderer.getPreference() and renderer.getRenderedPage() methods and the need to add an application scope respectively.


Hi Vaughn,



Thanks for the updates in the wiki. When I followed the steps I found that the scope was getting duplicated in the widget UI page URL if the scope call is in both the render() and getEditLink() functions as it currently has in docs/wiki. Following tltoulson and stephenfarrar advice I removed the scope from the render function and works great.


Is it possible to use this in a ServicePortal widget?   Not sure where renderer is defined?


Hi Daniel,



UI pages, UI macros and Jelly are not supported in Service Portal. If you want custom functionality in Service Portal you would want to create it using Angular in a portal widget.


Hi Ann,



I understand that.   Since there isn't a notification preferences widget, I'm trying to avoid re-writting it and hoping to just present it in the ServicePortal.



Dan