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

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);
}

}

})();

Hello Sir

I tried with the code still it is not working sir, 

Some code mistakes are there,i modified and uploading script,please check the attachments.

below image is output of my request and incident tables.

find_real_file.png

Thank you for your reply sir 

I am getting request tickets but at the same time, I need incident tickets also need to display I need in the same widget could you please help me......