How to display Incidents and Requests on Service portal,

sivakalyaan
Giga Contributor

Hello Guys 

I am new to service portal designing I need help to display the Incidents and Request on the service portal. 

I am attaching the HTML script and Server Script where i have created a widget where this function should work

I want these things to work

1....When status is Pending Approval then it should display the Notify Approver

2....Want to display the Incidents and Request Tickets in the same tablet

I have written the code successfully where i can display either REQUEST or INCIDENT but i am unable to display BOTH, 

So please help me

 

 

 

1 ACCEPTED SOLUTION

anjaneyulumuvva
Kilo Expert

Hi SivaKalyan,

 

you are retrieving data from 2 tables and preparing same format.then u can push in to one array (data.list).

and if status is Pending Approval then add one more value to list object "Notify Approval".

Please check below code. i have modified.

(function () {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */

// data.status='state';
// data.des='desc';
// data.num='numb';
// data.date='dat';
var data = {};
if (!options.maximum_entries) {
options.maximum_entries = 3;
var gr = new GlideRecord('sc_request');
var gi = new GlideRecord('incident');
gr.addQuery('opened_by', gs.getUserID());
gr.addQuery('active', 'true');
gr.orderByDesc('sys_created_on');
gr.query();
gi.addQuery('opened_by', gs.getUserID());
gi.addQuery('active', 'true');
gi.orderByDesc('sys_created_on');
gi.query();
data.count = gr.getRowCount();
data.count1 = gi.getRowCount();
data.list = [];
var recordIdx = 0;
while (gr.next()) {
if (recordIdx == options.maximum_entries)
break;

var record = {};
var STATUS = gr.getDisplayValue('request_state');
var DESCRIPTION = gr.getValue('short_description');
var NUMBER = gr.getValue('number');
var DATE = gr.getValue('opened_at');

record.status = STATUS;
record.description = DESCRIPTION;
record.number = NUMBER;
record.date = DATE;
if(STATUS =="Pending Approval"){
record.notify = "Notify Approval";
}else{
record.notify = "";
}
data.list.push(record);
}
data.list1 = [];
var recordIdx1 = 0;
while (gr.next()) {
if (recordIdx1 == options.maximum_entries)
break;

var record1 = {};
var STATUS1 = gr.getDisplayValue('u_request_state');
var DESCRIPTION1 = gr.getValue('short_description');
var NUMBER1 = gr.getValue('number');
var DATE1 = gr.getValue('opened_at');

record1.status = STATUS1;
record1.description = DESCRIPTION1;
record1.number = NUMBER1;
record1.date = DATE1;
if(STATUS1 =="Pending Approval"){
record.notify = "Notify Approval";
}else{
record.notify = "";
}
data.list.push(record1);
}

}

})();

View solution in original post

17 REPLIES 17

Content is available,but you are given limitTo 3,means it will show only top 3 records.

 

  <tr ng-repeat="rec in c.data.list| limitTo : 3">

if u remove that limit to it will show all requests and incidents.

Hello sir

Need some more help

when user click on notify approver a email need to trigger to the approver either incident or request tickets depends on that it should trigger the mail to concern so please help

we can send mail by eventQueue method.

please check below link 

https://developer.servicenow.com/app.do#!/api_doc?v=istanbul&id=r_ScopedGlideSystemEventQueue_String_Object_String_String_String