Service Portal : modify the widget 'my request'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2017 01:15 AM
Hello everyone,
I need your help, I would like to modify the table under the widget "my request".
Currently, when we click on the link 'My Requests' , we see the REQ tickets (sc_request) :
I would like to modify the widget in order to see only the RITM tickets (sc_req_item), I tried to modify the script but no success...
I replaced the table "sc_request" by "sc_req_item" (see screenshot above in green underline). After saving and checking, I get this message :
server script :
(function() {
if (!options.maximum_entries)
options.maximum_entries = 20;
var gr = new GlideRecordSecure('sc_req_item'); // does ACL checking for us
gr.addActiveQuery();
options.title = options.title || gr.getPlural();
data.display_field = 'sys_created_on';
data.secondary_fields = ['number','short_description','state'];
data.filterMsg = gs.getMessage("Filter...");
gr.addEncodedQuery('requested_for=javascript:gs.getUserID()');
gr.orderByDesc('sys_created_on');
gr.query();
data.count = gr.getRowCount();
data.list = [];
var recordIdx = 0;
while (gr.next()) {
if (recordIdx == options.maximum_entries)
break;
var record = {};
record.sys_id = gr.getValue('sys_id');
var ritm = new GlideRecord("sc_req_item");
ritm.addQuery("request", gr.getUniqueValue());
ritm.query();
if (ritm.getRowCount() == 0)
continue;
if (ritm.getRowCount() > 1)
record.display_field = gs.getMessage("{0} requested items", ritm.getRowCount());
else {
ritm.next();
record.display_field = ritm.cat_item.getDisplayValue() || ritm.getDisplayValue("short_description");
}
record.secondary_fields = [];
data.secondary_fields.forEach(function(f) {
record.secondary_fields.push(getField(gr, f));
});
record.url = {id: 'sc_request', table: 'sc_request', sys_id: record.sys_id};
data.list.push(record);
recordIdx++;
}
function getField(gr, name) {
var f = {};
f.display_value = gr.getDisplayValue(name);
f.value = gr.getValue(name);
var ge = gr.getElement(name);
f.type = ge.getED().getInternalType()
f.label = ge.getLabel();
return f;
}
})()
Sorry, I'm not developer, need your precious help.
Thanks in advance
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2017 09:05 PM
Hi,
Modify the server code alone, lines 21-42.
var record = {};
record.sys_id = gr.getValue('sys_id');
var ritm = new GlideRecord("sc_req_item");
ritm.addQuery("request", gr.getUniqueValue());
ritm.query();
if (ritm.getRowCount() == 0)
continue;
if (ritm.getRowCount() > 1)
record.display_field = gs.getMessage("{0} requested items", ritm.getRowCount());
else {
ritm.next();
record.display_field = ritm.cat_item.getDisplayValue() || ritm.getDisplayValue("short_description");
}
record.secondary_fields = [];
data.secondary_fields.forEach(function(f) {
record.secondary_fields.push(getField(ritm, f));
});
record.url = {id: 'ticket', table: 'sc_req_item', sys_id: ritm.getValue('sys_id')};
data.list.push(record);
recordIdx++;
}
Darshak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2017 02:16 PM
Hi khamsone
You can use OOB widget "Simple List" to get the same functionality.
Example :
Additional Options:
{
"always_show": {
"displayValue": true,
"value": true
},
"image_field": {
"value": null,
"displayValue": ""
},
"secondary_fields": {
"value": "number,sys_updated_on",
"displayValue": "number,sys_updated_on"
},
"panel_body_height": {
"value": null,
"displayValue": ""
},
"rounded_images": {
"displayValue": true,
"value": true
},
"list_page": {
"value": "issu",
"displayValue": "issu"
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2017 01:48 AM
Hope you already found the answer, if not please replace the below script in your server side code.
(function() {
if (!options.maximum_entries)
options.maximum_entries = 20;
var gr = new GlideRecordSecure('sc_req_item'); // does ACL checking for us
//gr.addActiveQuery();
options.title = options.title || gr.getPlural();
data.display_field = 'sys_created_on';
data.secondary_fields = ['number','sys_updated_on'];
data.filterMsg = gs.getMessage("Filter...");
gr.addEncodedQuery('requested_for=javascript:gs.getUserID()');
gr.orderByDesc('sys_created_on');
gr.query();
data.count = gr.getRowCount();
data.list = [];
var recordIdx = 0;
while (gr.next()) {
if (recordIdx == options.maximum_entries)
break;
var record = {};
record.sys_id = gr.getValue('sys_id');
record.display_field = gr.cat_item.getDisplayValue() || gr.getDisplayValue("short_description");
record.secondary_fields = [];
data.secondary_fields.forEach(function(f) {
record.secondary_fields.push(getField(gr, f));
});
record.url = {id: 'sc_request', table: 'sc_req_item', sys_id: record.sys_id};
data.list.push(record);
recordIdx++;
}
function getField(gr, name) {
var f = {};
f.display_value = gr.getDisplayValue(name);
f.value = gr.getValue(name);
var ge = gr.getElement(name);
f.type = ge.getED().getInternalType()
f.label = ge.getLabel();
return f;
}
})()