Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Cannot find function getPreferences in object com.glide.script.fencing.ScopedRenderJavascript

mikeb
Tera Contributor

I'm trying to add a UI page to a Widget to use on a Dashboard in a Scoped App - here's the script, straight out of the docs:

function sections() {
 return {
  'Activity Report': { 'uiPageName' : 'x_asdf_network_ma.progress_report'},
  'Quarterly Report': {'uiPageName': 'x_asdf_network_ma.quarterly_report'}
 };
}

function render() {
  var uiPageName = renderer.getPreferences().get("uiPageName");
  return renderer.getRenderedPage(uiPageName);
}

function getEditLink() {
  var uiPageName = renderer.getPreference('uiPageName');
  return 'sys_ui_page.do?sysparm_query=' + encodeURIComponent('name=' + uiPageName);
}

The page renders with `null` and I get the error in the console: Cannot find function getPreferences in object com.glide.script.fencing.ScopedRenderJavascript

Clearly, the ScopedRenderJavascript object is not the same as the Global one.

How can I do this in a scoped app? The UI page is great, but my users need to be able to add it to a dashboard.

 

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

In scope you'll need to change: 

var uiPageName = renderer.getPreferences().get("uiPageName");

to:

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

There is a bit more info here:

KB0754978

View solution in original post

1 REPLY 1

Brad Tilton
ServiceNow Employee
ServiceNow Employee

In scope you'll need to change: 

var uiPageName = renderer.getPreferences().get("uiPageName");

to:

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

There is a bit more info here:

KB0754978