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

Hi Seth, I really appreciate the pointer to My Request Filters. I am trying to add the Interaction table but it is not available on table field. Do you have any idea on this? 

Thanks!

I'm on holiday and cannot log in right now, but this is probably because Interactions are not an extension of the Task table. 

Hi Seth,

Appreciate your reply. You are correct. I removed the dictionary overrride to allow tables not extended from Task I am able to select Interaction and define the filter but no results are shown in My request list. 

If you happen to know if this could be overcome I cannot see how

Many Thanks