logo

NJP

ServiceNow "problems" in table format view: Service Portal

Import · Jan 30, 2018 · article

Hi ServiceNow Developers:

I have worked on one of a widget which helps you to view problems in table format.

This widget includes pagination, search and print functions.

Hope this document helps developers to learn something new.

How it looks like:

image

Followed by other problems

HTML template:

<div class="range-label">Displaying {{ range.lower }} - {{ range.upper }} of {{ range.total }}</div>

Print


Search by:

problems in

{{problem.number}} : {{problem.short\_description}}

Number {{problem.number}} Opened {{problem.opened\_at}}
Configuration item {{problem.cmdb\_ci}} Opened by {{problem.opened\_by}}
Impact {{problem.impact}} State {{problem.state}}
Urgency {{problem.urgency}} Assignment group {{problem.assignment\_group}}
Priority {{problem.priority}} Assignment to {{problem.assigned\_to}}
Change request {{problem.rfc}} Vendor {{problem.u\_vendor}}
Known error {{problem.known\_error}} Vendor Ticket Number {{problem.u\_vendor\_ticket\_number}}
First Incident {{problem.u\_first\_incident}} Work notes list {{problem.work\_notes\_list}}
Short description {{problem.short\_description}}
Description {{problem.description}}
Closure Information IT SOC
Causing CI {{problem.u\_causing\_ci}} Timeline {{problem.u\_timeline}}
Close notes {{problem.close\_notes}} Executive Summary {{problem.u\_executive\_summary}}
Closed {{problem.closed\_at}} Business Impact {{problem.u\_business\_impact}}
Closed by {{problem.closed\_by}} Root Cause {{problem.u\_root\_cause}}

Print

CSS:

.appheader {

margin-top:20px;

}

.appname {

background:#819FF7 !important;

color: #FFFFFF !important;

font-weight:bold !important;

font-size: medium !important;

}

.tableheader {

background:#DDDDDD !important;

color: #343d47 !important;

font-weight:bold;

font-size: medium;

}

table, th, td{

border: 1px solid black;

}

Client Script:

function($scope) {

/* widget controller */

var c = this;

c.options = [{name: 'Open'}, {name: 'Close'}];

c.server.update().then(function(response) {

});

}

Server Script:

(function() {

data.problems = [];

var openORclose = 'Open';

if(input){

openORclose = input.dropDown.Value.name;

}

var grInc = new GlideRecord('problem');

if(openORclose == 'Open'){

grInc.addQuery("active=true");

}else if(openORclose == 'Close'){

grInc.addQuery("active=false");

}

grInc.orderBy('number');

grInc.query();

while(grInc.next()){

var problem = {};

problem.number = grInc.getDisplayValue('number');

problem.opened_at = grInc.getDisplayValue('opened_at');

problem.cmdb_ci = grInc.getDisplayValue('cmdb_ci');

problem.opened_by = grInc.getDisplayValue('opened_by');

problem.impact = grInc.getDisplayValue('impact');

problem.state = grInc.getDisplayValue('state');

problem.urgency = grInc.getDisplayValue('urgency');

problem.assignment_group = grInc.getDisplayValue('assignment_group');

problem.priority = grInc.getDisplayValue('priority');

problem.assigned_to = grInc.getDisplayValue('assigned_to');

problem.rfc = grInc.getDisplayValue('rfc');

problem.u_vendor = grInc.getDisplayValue('u_vendor');

problem.known_error = grInc.getDisplayValue('known_error');

problem.u_vendor_ticket_number = grInc.getDisplayValue('u_vendor_ticket_number');

problem.u_first_incident = grInc.getDisplayValue('u_first_incident');

problem.work_notes_list = grInc.getDisplayValue('work_notes_list');

problem.short_description = grInc.getDisplayValue('short_description');

problem.description = grInc.getDisplayValue('description');

problem.u_causing_ci = grInc.getDisplayValue('u_causing_ci');

problem.u_timeline = grInc.getDisplayValue('u_timeline');

problem.close_notes = grInc.getDisplayValue('close_notes');

problem.u_executive_summary = grInc.getDisplayValue('u_executive_summary');

problem.closed_at = grInc.getDisplayValue('closed_at');

problem.u_business_impact = grInc.getDisplayValue('u_business_impact');

problem.closed_by = grInc.getDisplayValue('closed_by');

problem.u_root_cause = grInc.getDisplayValue('u_root_cause');

data.problems.push(problem);

}

})();

This Widget has a dependency for pagination please include it in your widget.(Hope you know how to do it), I have attached it here.

View original source

https://www.servicenow.com/community/developer-articles/servicenow-quot-problems-quot-in-table-format-view-service/ta-p/2329871