- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2016 06:42 PM
Hello,
I am trying to query the assignment_group in my tasks table but I think I am hitting an error due to my lack of understanding the user groups.
I want to filter for the assignment group called AOM-OU. I tried replacing assignment_group with sys_user_group since I noticed that this was a reference field in the form.
var tasks = new GlideRecord('sc_task');
tasks.addQuery('sys_user_group', 'AOM-OU');
tasks.query();
This should be a simple query but I'm not sure where I am going wrong...
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2016 08:13 PM
- var tasks = new GlideRecord('sc_task');
- tasks.addQuery('assignment_group', 'sys_ID'); //sys Id of assignment group
- tasks.query();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2016 07:37 AM
Yeah!
I went to user groups in servicenow and then clicked into the user group and right clicked to copy over the sys ID
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2016 07:56 AM
Hi Zhen
Thanks for the revert
I am new to service now and still learning, I wanted to enquire where the below code was put/checked by you in SNow...
- var tasks = new GlideRecord('sc_task');
- tasks.addQuery('assignment_group', 'sys_ID'); //sys Id of assignment group
- tasks.query();
was it business rule/script ???
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2016 08:10 AM
So I needed to query for data from the tasks table that had a certain sys_id to another table. In order to do this, I used a scheduled job since I need to capture the data on a monthly basis. And then I click 'Execute' to execute the script so I can see the results. Let me know if you have further questions!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2016 08:10 AM
Could you tell me where did you run the script and what where the conditions used, if any
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2016 08:14 AM
System Definition > Scheduled Jobs
Create a new scheduled job
//this defines the where I want to pull data from
//so I am pulling data from the sc_task table, with the specific assignment group with sys_id of 103847533dfww
var tasks = new GlideRecord('sc_task');
tasks.addQuery('assignment_group', '103847533dfww'); //sys Id of assignment group
tasks.query();
//so if the script finds any data that meets the above criteria
//do this to each record...
while (tasks.next()) {
//place the data in the following table:
var table = new GlideRecord('u_table');
//look for the field name in the table called u_assignment_group
table.u_assignment_group = tasks.assignment_group.getDisplayValue();
//insert the data record in the field
table.insert();
}