Create a list of task types
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2016 03:56 AM
Hi guys, I'm working on something where I need to be able to have a list field with the available task types, so I can choose if a ticket can be assigned to a group based on the task type.
I know that when on task we can create a filter based on the task type, but my question is where can I get all the task types on the system ? I know I can use the sys_db_object to query for the tables but my problem is that we have task types that don't come directly from the task table but from other tables that extend task.
Is there anyone that knows any way of getting all the task types as the filter on task does ?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2016 05:10 AM
Task Type is a field on the Task table (sys_class_name). When you filter a list of tasks it is simply filtering on the values in sys_class_name.
You can get a list of task types in your instance by creating a query to get the unique values for sys_class_name. One way to do this is with the GlideAggregate method.
var count = new GlideAggregate('task');
count.addAggregate('COUNT', 'sys_class_name');
count.orderBy('sys_class_name');
count.query();
while (count.next()) {
var taskType = count.sys_class_name;
var taskCount = count.getAggregate('COUNT', 'sys_class_name');
gs.info(taskType + ' : ' + taskCount);
}
The output of this in my Helsinki developer instance is:
change_request : 2278
change_task : 2540
dmn_demand : 239
dmn_requirement : 1
grc_audit : 1
grc_remediation : 1
incident : 13725
pm_project : 124
pm_project_task : 1038
problem : 92
reconcile_duplicate_task : 12
rm_enhancement : 1
sc_request : 2811
sc_req_item : 3921
sc_task : 6732
sn_audit_activity : 5
sn_audit_engagement : 3
sn_grc_issue : 1
sysapproval_group : 540
tm_test_case_instance : 288
tm_test_plan : 42
u_application_issues : 676
vtb_task : 758
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2016 07:06 AM
Hello Michael,
Thanks for your reply, the only problem that I can see with your solution is that it will only show tasks types for which there's a record in the task table, in my case I would like to get all task types (so I can duplicate the filter that is used by the system), so for this I found that if you use getTableExtensions('task'); I get all task types even if they don't have any record (and it's faster).
Thanks