Add encoded query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2015 11:43 AM
I have created a CI field that is a list. How can i write an encoded query to change the line that is not working below to an encoded query are both the queries on line 5 and 6 the same? I am trying to match a CI that is in a list.
if (current.u_configuration_item != "") {
var gr = new GlideRecord('u_maint');
//gr.addQuery('u_configuration_item','IN', current.u_configuration_item); This line is not working correctly
gr.addEncodedQuery(u_configuration_item>=current.u_configuration_item); Switch the above query out with an encoded query
gr.addQuery('state', 2);
if (gr.next()) {
current.u_event_state = 3;
current.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2015 12:24 PM
You should be able to accomplish this with the following encoded query:
gr.addEncodedQuery('u_configuration_itemIN' + current.u_configuration_item.toString());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2015 12:35 PM
Travis is correct though I also noticed you have another addQuery for state as well. You will need to combine all of those into the 1 addEncodedQuery statement:
gr.addEncodedQuery('state=2^u_configuration_itemIN' + current.u_configuration_item.toString());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2015 01:00 PM
Good catch, Michael Ritchie, I didn't even notice that. Unless you have a particular preference for keeping them separate, I would go with Michael's approach. I find its easier to read and edit a query if you avoid mixing addQuery and addEncodedQuery.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2015 10:49 AM
For some reason this script is still matching CI events that are not in an active maintenance mode. How can i tell why this script is matching those events and changing the state to 3?