GROUP_CONCAT Concatenates all non-null values of the group in ascending order, joins them with a comma (','), and returns the result as a String.
var incidentGA = new GlideAggregate('incident'); incidentGA.groupBy('category'); incidentGA.addAggregate('GROUP_CONCAT', 'sys_id'); incidentGA.addAggregate('GROUP_CONCAT_DISTINCT', 'sys_id'); incidentGA.query(); while (incidentGA.next()) { gs.info('GROUP_CONCAT: ' + incidentGA.getAggregate('GROUP_CONCAT', 'sys_id')); gs.info('GROUP_CONCAT_DISTINCT: ' + incidentGA.getAggregate('GROUP_CONCAT_DISTINCT', 'sys_id')); }
User of GROUP_CONCAT in GlideAggregate with example in ServiceNow
Working Code Edited question September 21, 2023