Using the Standard Ticket Widget with Custom Tables in ServiceNow

Configuring the Standard Ticket Widget in ServiceNow to support custom and non-task tables.

Using the Standard Ticket Widget with Custom Tables in ServiceNow

The Standard Ticket widget came out not too many versions ago now and with it a bunch of ground gears for yours truly.

The heart of my frustration came with the inability to use it with Custom or Non-Task tables, however NOT TO FEAR!

Below I outline a method I've used to allow custom and non-task tables to be used with the standard ticket widget, hopefully this assists a few of you out there that do a lot of custom portal work.

Update the Standard Widget Configuration

First, we want to modify the table field on the form by right clicking and going to configure dictionary.

Next, we want to remove an attribute from the Attributes field, I believe its called "base_table = task". This will remove the task based limitation for the field. Save the dictionary record.

Now we can go in and create a new Standard Ticket Configuration for our custom or non-task table. Select the table name from the now unblocked table selection field.

You may find you get errors using the Activity tab configuration, this is most likely cause of this is not having a work notes field on your custom table.

Now additionally, we can create a new Tab configuration so we can display all the fields we want from our custom table.

Create a new widget and link to it from the Tab Configuration Record.

Whilst on the Tab Configuration Record, we want to link it to the new widget we will create below, we also want to add the following key/value pair widget parameters to feed what we want to the widget.

table - custom_table_name
sys_id - javascript:current.getUniqueValue();
fields - comma,separated,list,of,field,names,to,display
Widget Paramaters (name - value)

Widget code below for grabbing all the fields off your table, customise as you see fit.

<div>
  <div ng-repeat="field in data.fieldData">
    <strong>{{field.label}}</strong>
    <p>
      {{field.value}}
    </p>
  </div>
</div>
HTML Template
api.controller=function() {
  /* widget controller */
  var c = this;
};
Client Script
(function() {
	try{
	 data.table = options.table;
	 data.sys_id = options.sys_id;
	 data.fields = options.fields;

	 if(data.table && data.sys_id){
	  var gr = new GlideRecord(data.table);
	  if(gr.get(data.sys_id)){
	   if(data.fields){
	    var splitFields = data.fields.split(",");
	    data.fieldData = [];
	    for(var i=0;i<splitFields.length;i++){
	     var name = gr.getElement(splitFields[i]).getLabel();
	     var dataobject = {
	      "label":name,
	      "value":gr.getDisplayValue(splitFields[i])
	     };
	     if(gr.getDisplayValue(splitFields[i]) != ""){
	      data.fieldData.push(dataobject);
	     }
	    }
	   }
   	 }
	}
	}catch(e){
	 console.log(e);
	}
})();
Server Script

Here is the output of the custom Tab Configuration showing you all the table fields.

Some information redacted to preserve privacy

I hope this helps some of you!