- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2022 09:52 AM
Hi All,
I wanted to check if an incident record is available with either resolved state or closed state or cancelled state
is below script for querying the table right?
inc.addQuery('state=7'||'state=6'||'state=8'); // is this querying right?? as am not getting the output
Please advice
Regards,
Sandeep
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2022 04:34 AM
Hi,
The suggested addEncodedQuery is 1 option.
You can also do it via the addOrCondition:
var grIncident2 = new GlideRecord('incident');
grIncident2.addQuery('incident_state',6).addOrCondition('incident_state',7).addOrCondition('incident_state',8);
grIncident2.query();
gs.print("COUNT IS : " + grIncident2.getRowCount());
Or even via the addQuery with IN:
var grIncident = new GlideRecord('incident');
grIncident.addQuery('incident_stateIN6,7,8');
grIncident.query();
gs.print("COUNT IS : " + grIncident.getRowCount());
Regards,- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2022 10:05 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2022 10:44 AM
Hello,
Please use it as
inc.addEncodedQuery('stateIN6,7,8');
Please mark answer correct/helpful based on Impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2022 10:10 AM
Hello Sandeep,
Just saw you had marked my answer as correct and then changed it.
Any reason why?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2022 03:57 AM
Hi Sandeep,
Try the below code in Background script. It will give you the count of either Incident resolved or closed or cancelled state.
var incstate = new GlideRecord('incident');
incstate.addEncodedQuery('incident_stateIN6,7,8');
incstate.query();
gs.print("COUNT IS--" + incstate.getRowCount());
If you want some manipulation after this
var incstate = new GlideRecord('incident');
incstate.addEncodedQuery('incident_stateIN6,7,8');
incstate.query();
while (incstate.next()
{
//Your code
}