- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017 06:05 AM
So,
I am doing this out of a workflow script:
var gr = new GlideRecord('table');
gr.addQuery('requested_item', current.number) //current.number is the correct RITM that I am expecting
gr.query();
//here's where I scratch my head
if (gr.next()) {
gs.info('found record with ritm: ' + current.number);
gr.setValue('status', 2);
gr.update();
}
else {
gs.info('could not find record');
}
This is returning the "could not find record" in the logs. But when I go to the table and manually add the filter:
requested item , is, RITMXXXXX
It pulls up the record I am searching for. So I know this means my query must be off but I'm not sure where / how. Could anyone help me out?
Thank you.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017 06:30 AM
replace your addQuery with following
gr.addQuery('requested_item.number', current.number);
(;) is missing in your addQuery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017 06:12 AM
Hello. I usually put an operator in my addQuery tag. You might try adding ",'='" in between the two parameters. See below.
gr.addQuery('requested_item', '=', current.number)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017 06:17 AM
Same message. It came up empty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017 06:21 AM
not sure if this is solution to your issue or not:
var gr = new GlideRecord('table');
here first replace 'table' to correct table name
and replace your addQuery with following
gr.addQuery('requested_item.number', current.number)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017 06:22 AM
Ben,
I looks like your first list is not specifying what table to query. You have "var gr = new GlideRecord('table'); " you will need to specify what table to query. Below is an example for querying the "Requested Item" table
var gr = new GlideRecord('sc_req_item');