Comment
ServiceNow Employee
ServiceNow Employee

Original script re-written using GlideAggregate and filtering out flow snapshots

var actions = new GlideAggregate('sys_hub_action_instance');
actions.addQuery('flow.sys_class_name', 'sys_hub_flow');

var action_variables = actions.addJoinQuery('sys_variable_value', 'sys_id', 'document_key');

action_variables.addCondition('value', 'incident');

actions.addAggregate('GROUP_CONCAT_DISTINCT', 'flow.sys_id');
actions.groupBy('flow.sys_class_name');

actions.query();

var flows = [];

if(actions.next())
	flows = actions.getAggregate('GROUP_CONCAT_DISTINCT', 'flow.sys_id').split(',');