CUSTOM GAUGE — 101
In this Custom Gauge — 101 series, we will learn "How to make custom Gauge". After creating we will place that gauge on our incident form and bind it with an integer field so that, gauge value can change dynamically.
Impressive UI — Custom Gauge
To start this, we will need:
- UI Scripts
- UI Macro
- UI Formatter — To show UI Macro on incident form
- Create a Field name "u_visitors" of type "Integer" on incident table.
Steps:
Before starting our process, lets have a story-line for this example. We have a field on incident table and we want to show a percentage indicator(off-course UI indicator). So, let's start.
Step 1:- Adding justgage and raphael in SN
- Create UI Scripts for justgage.js as well as raphael.js
- You can copy script code from above CDN links or copy code from github repository
- If ServiceNow throws error while trying to save script files than save a blank script and use the list edit to save the script content.Download UI Scripts
Step 2:- Creating UI Macro
Now, it's time to create magical UI Macro that will perform magic for us.
- Create new UI Macro and name it as "visitors"
- Add the following code into UI Macro
<?xml version="1.0" encoding="utf-8" ?>
<!-- Add a div containing gauge div -->
Visitor's %age
Step 3:- Create UI Formatter
- Create a UI Formatter for above created UI Macro. Take help from here
- Name this Formatter as "visitors macro" and fill the entries like below:
UI Formatter
Step 4:- Modify Incident Form
- Modify incident table and create new field "u_visitors" of "Integer" data type.
- Modify form layout and bring "visitors macro" formatter on form like below
Macro on Incident Form
And, we are done. It was easy, RIGHT?
IF you don't want to create yourself, no problem, we have already done it for you. Just Download UpdateSet from our github repository. You can also fork our public repository.
To read more such interesting posts. Click here
----
visit www.inMorphis.com/blogs/ for more
https://www.servicenow.com/community/north-texas-snug/custom-gauge-101/ba-p/2286201