The CreatorCon Call for Content is officially open! Get started here.

How to query multiple values in a 'state'

Sandeep109
Mega Contributor

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

 




1 ACCEPTED SOLUTION

Hayo Lubbers
Kilo Sage

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,
Hayo

View solution in original post

7 REPLIES 7

Hayo Lubbers
Kilo Sage

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,
Hayo

shloke04
Kilo Patron

Hi,

Where are you writing this code , can you let me know and accordingly can assist you with the sample code to be used.

Regards,

Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hi Sholke,

Got the answer from the above replies

Thanks anyways