Custom dashboard widget development

arjun_basnet
Giga Contributor

I have been trying to create custom widget to be added on Dashboard. I found a way to achieve the goal with limited customization option here.

https://docs.servicenow.com/bundle/helsinki-platform-user-interface/page/script/server-scripting/task/t_UsingUIPagesAsGauges.html

I looked into other System UI > Widget with render type = JavaScript  definitions the technique used there are more suited to Global scope.

The community post suggests me that portal widget can not be used in dashboard, I believe there is no alternative?

When followed "Create a widget that displays a ServiceNow UI Page" steps, it throws following warning, however the page does gets rendered. Since the page is no longer available in later release, it might be deprecated

org.mozilla.javascript.EcmaError: Cannot find function getProperty in object com.glide.script.fencing.ScopedGlideSession@1b8fcfc.
Caused by error in sys_widgets.cb3d0c76db4f73002793797b8c961938.script

Does anyone know how to create custom widgets that can be used in dashboards?

4 REPLIES 4

Harish KM
Kilo Patron
Kilo Patron

Check this 

https://community.servicenow.com/community?id=community_article&sys_id=c48db33ddb356700107d5583ca9619a5

Regards
Harish

Hello Harish,

 

On the link you provided it works for global scope however for scoped application the line with

 return renderer.getRenderedPage(name);

throws error

Hey @arjun.basnet ,

I am running into the same problem , do you get to know how to work it out for scoped application?

Afsar2
Tera Contributor

Hi @arjun.basnet & @gurjit ,

I was also stuck with the same issue.

Here are my findings.

Issue: Following method is not available in scoped app

return renderer.getPreferences().get("uiPageName"); 

 

 

For UI page in scoped app use following:

To get page name use

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

To render

return renderer.getRenderedPage(scope+uipagename);

 

you can get scope as follows

var scope = gs.getCurrentScopeName();

 

Disclaimer

renderer.getPreference("uiPageName");

//returns page name with space in between (if camel case)
eg:Page name "WeatherData" will appear as "Weather Data".

 

Please refer the following

https://community.servicenow.com/community?id=community_question&sys_id=5faffe2ddb58dbc01dcaf3231f96...

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0754978

 

It is working for me.

 

Please mark helpful.