Adding Non-Task tables to the My Tickets widget in ServiceNow

Adding Non-Task tables to the My Tickets widget in ServiceNow

Here is a simple block of code that you can replicate and modify in your ServiceNow "My Tickets" widget in order to show tickets that do not extend the Task table.

Our example below works for the Interaction table, you can modify this to work for any table you desire.

var interactions = new GlideRecord("interaction");
	interactions.addEncodedQuery("opened_forDYNAMIC90d1921e5f510100a9ad2572f2b477fe");
	if (localInput && localInput.search_text) {
		interactions.addQuery('123TEXTQUERY321', localInput.search_text);
	}
	if (localInput && localInput.view === 'open') 
		interactions.addQuery('active', 1);
	else if (localInput && localInput.view === 'close')
		interactions.addQuery('active', 0);
	else
		interactions.addQuery('active', 1);
	interactions.query();
	while(interactions.next()){
		// Look up the attached interaction record
		var interactionRelatedRecord = new GlideRecord("interaction_related_record");
		interactionRelatedRecord.addQuery("interaction",interactions.getValue("sys_id"));
		interactionRelatedRecord.query();
		if(!interactionRelatedRecord.next()){
			// Interaction has not been converted to another record
			data.tickets.push({
				sys_id:interactions.getUniqueValue(),
				number:interactions.getValue("number"),
				title:interactions.getValue("short_description"),
				status:interactions.getDisplayValue("state"),
				created:interactions.getValue("sys_created_on"),
				url:{ id:'ticket', table: 'interaction', sys_id: interactions.getUniqueValue()}
			});
		}
	}
Server Script