- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2018 08:41 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2018 09:13 PM
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);
}
}
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2018 06:42 PM
ya,
in previous reply image having output of incidents and requests,
in Number column starting with REQ... is Requests,starting with INC... is Incidents.
Please look into that once.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2018 07:11 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2018 07:25 PM
you mean to say any relation with incident and request.first row request record,second row is first request records incident like this..
or
order by date ascend or descend?
what is the scenario please tell me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2018 07:41 PM
We need to populate incident and request in that table like the latest 2incidents and 2 request tickets,
Tickets Messages Worklist
status Description Ticket number Date
PendingApproval Ticket description REQ12345 3/14/2018 Notify Approver
Ticket description INC12345 3/14/2018
Ticket description REQ12345 3/14/2018
PendingApproval Ticket description INC12345 3/14/2018 Notify Approver
1......If pending approval then notify approver will populate else it will not display for request or incident
2......The bold parts are TAB in the table if we click on the ticket we get details of tickets if we click on messages tab then the message should populate, similarly worklist also get the same
this is the actual requirement sir, So please help me sir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2018 08:06 PM
in client script please add below code
c.data.list.sort(function(a,b) {
return new Date(b.date) - new Date(a.date);
});
in html data.list replace with c.data.list. it will sort the data in descending order by date.