Adding Change Requests to the "My Requests" widget

sethhumphrey
Mega Guru

I would like to combine Change Requests with Service Catalog Requests in the "My Requests" Service Portal widget.

I have successfully added Change Requests into the navigation menu:

find_real_file.png

And I successfully cloned the My Requests widget and altered the Server Script so that it displays my changes requests but my end-users don't need to know the difference between the types of requests so I want to combine the change requests in with the service catalog requests.  Can anyone help me out?

find_real_file.png

The My Requests server script is OOB.  Here is my alterations to make it display changes only:

(function() {

	if (!options.maximum_entries)
		options.maximum_entries = 20;
	//var gr = new GlideRecordSecure('sc_request'); // does ACL checking for us
	var gr = new GlideRecordSecure('change_request');
	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('opened_by=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");
		var ritm = new GlideRecord("change_request");
		ritm.addQuery("request", gr.getUniqueValue());
		ritm.orderByDesc('sys_created_on');
		ritm.query();
		if (ritm.getRowCount() == 0) {
			continue;
		}
// ELSE added by Seth
		else {
			record.display_field = gs.getMessage(gr.getDisplayValue("short_description"));
		}

//		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};
		record.url = {id: 'ticket', table: 'change_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;
	}
})()
1 ACCEPTED SOLUTION

I highly recommend abandoning the path I took above and use the OOB My Request widget.  This widget can be maintained within the platform using the My Request Filters for easy configuration.

View solution in original post

7 REPLIES 7

Shane J
Tera Guru

Repeat what you did but point at the Task table instead, and only include the Classes you want shown.

 

We have a custom widget and took advantage of Instance options to handle this differently, so it's not just a matter of me handing over my script unfortunately.

randrews
Tera Guru

I looked pretty hard at the new tool to show multiple types of requests... finally decided it wasn't worth it...

 

the problem is to get multiple record types to show you have to point the base tool to the task table.. which means the fields from the individual records won't show.. this means..

 

on requests.. no requested for etc...

on incidents.. no caller.. etc..

on change requests <the one you want> no planned start/end dates...

 

i could go on.. but the bottom line is that while it is interesting... it is less than usefull because most of the record types have VERY important fields that are NOT on the taks table and those fields won't be available from the task table.

 

Annie10
Tera Contributor

Hi Sethhumphrey,

We wanted the end users to be able to view their change requests on Service Portal, My Requests.

Could you please share the steps how you get it to work?

Thank you so much

I highly recommend abandoning the path I took above and use the OOB My Request widget.  This widget can be maintained within the platform using the My Request Filters for easy configuration.