Activities on Service Portal

Balu Rathod
Tera Guru
We have requirement to show the Activity logs on Portal same as it showing in Backend UI of ServiceNow in Activity Formatter (Activities (filtered)).
 
But the issue we are having only Additional comment and work_notes are showing on the table record showing using 'Form' page which using 'Ticket Conversion' widget to show these two fields activity on portal.
 
We want show specific fields that are in Activity Formatter like changes to priority field on incident form, we have added in Configuring Activities slush bucket in backend UI of form
 
Please check below screenshots.
 
Please let me know if you have anything on the requirement.
3 REPLIES 3

BK22
Tera Contributor

Hi,

 

I'm looking to do the same in our portal. Did you get a chance to figure out how to add additional fields to the log? Any help would be much appreciated.

JMO1
Tera Contributor

We were able to create a custom widget to capture the activity log. Basically you need to query the History Set and History Set Line tables and then parse out the data. You can start it out like this:

 

        new GlideHistorySet(table, sys_id).generate();
	var stream = [];
	var gr = new GlideRecord("sys_history_set");
	gr.addQuery("table", table);
	gr.addQuery("id", sys_id);
	gr.addQuery('domain',domain);
	gr.addQuery('date_format',date + ' ' + time);
	gr.addQuery('time_zone',timezone);
	gr.addQuery('language',language);
	gr.orderByDesc("sys_created_on");
	gr.query();	

	while(gr.next()){
		var grl = new GlideRecord("sys_history_line");
		grl.addQuery("set", gr.sys_id);
		grl.addQuery("field", "IN", gs.getProperty('glide.ui.' + table + '_activity.fields'));
		grl.orderByDesc("update_time");
		grl.query();
		while(grl.next()) {
			//GET YOUR AUDIT DATA HERE

		}
	}

  

BK22
Tera Contributor

Thank you!

May I ask how you are listing the results? Is it a string field that you added to the table?