- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2016 05:45 AM
I just enabled the service desk call module, and I'm trying to setup a few things to use it. I have a script that pulls in all the records in the new_call table that haven't been moved to an incident/problem/whatever yet. I'm doing this by querying for records that were opened by me, but have no transfered_to value. This works just fine. I'm pulling in all the records I expect to find. However, I'm not able to get the sys_id field for these records. I even tried enumerating all the fields, and sys_id never shows up. If I go to the list of records in the new_call table, I can right-click on the record get its sys_id, so I know it has one. It's just not showing up in the GlideRecord query. Is there something special about the new_call table that's making this happen? Is there something new I need to add to the query to get it to return the sys_id?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2016 05:49 AM
Hi Tim,
Can you share your code?
Normally I would build an array for something like this to get a list of sys_ids.
var callArr = [];
var call = new GlideRecord('new_call');
call.addQuery('opened_by', gs.getUserID());
call.addNullQuery('transferred_to');
call.orderBy('number');
call.query();
while (call.next()) {
callArr.push(call.getValue('sys_id'));
}
// Now callArr is a list of all sys_ids matching the query above.
(revised 6:01AM PT to include Tim's query statements w/modification to the null query)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2016 05:49 AM
can you post the script you're using?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2016 05:54 AM
The following script is what I'm using to look for all fields:
var cgr = new GlideRecord('new_call');
cgr.addQuery('opened_by', gs.getUserID());
cgr.addQuery('transferred_to', null);
cgr.orderBy('number');
cgr.query();
while (cgr.next()) {
var fields = cgr.getFields();
for (var i = 0; i < fields.size(); i++) {
var element = fields.get(i);
gs.print("Element " + element.getName() + " has value " + element);
}
}
The response from this is:
*** Script: Element sys_tags has value
*** Script: Element opened_by has value 37ff6a110fda824088006509b1050ecc
*** Script: Element request_item has value
*** Script: Element description has value asdfasdfasdf
*** Script: Element caller has value 37ff6a110fda824088006509b1050ecc
*** Script: Element short_description has value Service Now case opened by Timothy Horn
*** Script: Element opened_at has value 2016-06-10 12:13:31
*** Script: Element sys_created_by has value THorn
*** Script: Element sys_domain has value global
*** Script: Element sys_updated_by has value THorn
*** Script: Element time_spent has value 1970-01-01 00:00:00
*** Script: Element transferred_to has value
*** Script: Element sys_mod_count has value 0
*** Script: Element sys_created_on has value 2016-06-10 12:13:31
*** Script: Element contact_type has value self-service
*** Script: Element company has value
*** Script: Element sys_updated_on has value 2016-06-10 12:13:31
*** Script: Element call_type has value general_inquiry
*** Script: Element number has value CALL0001019
You'll notice there is no sys_id in there.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2016 06:03 AM
Hi Tim,
That's pretty bizarre. Try the script (freshly updated) that I wrote in scripts background and see if it produces something you can use.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2016 05:49 AM
Hi Tim,
Can you share your code?
Normally I would build an array for something like this to get a list of sys_ids.
var callArr = [];
var call = new GlideRecord('new_call');
call.addQuery('opened_by', gs.getUserID());
call.addNullQuery('transferred_to');
call.orderBy('number');
call.query();
while (call.next()) {
callArr.push(call.getValue('sys_id'));
}
// Now callArr is a list of all sys_ids matching the query above.
(revised 6:01AM PT to include Tim's query statements w/modification to the null query)