- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2022 06:19 AM
Hi,
I want to filter records on incident table with reference field "assignment_group doesn't contain network".
var gr = new GlideRecord('incident');
gr.query(),
if(gr.assignment_group.name!="net") //I have used this way and tried with indexOf but it is not working. i want to filter "assignment_group doesn't contain net" through only if condition not encoded query
{
}
Thanks in advance!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2022 03:44 AM
Hi
You can try this
below code check if assignment group name does not have word 'network' and prints the incident number.
var gr = new GlideRecord('incident');
gr.query();
while(gr.next()){
if(gr.assignment_group.name.toLowerCase().indexOf('network') < 0){
gs.info(gr.number);
}
}
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2022 03:10 AM
Hi @Voona Rohila
Thanks for the reply. My requirement to use if condition not querying gliderecord.
var gr = new GlideRecord('incident');
gr.query();
if(gr.assignment_group.name!="network") // like this I want
{
}
Thanks!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2022 03:44 AM
Hi
You can try this
below code check if assignment group name does not have word 'network' and prints the incident number.
var gr = new GlideRecord('incident');
gr.query();
while(gr.next()){
if(gr.assignment_group.name.toLowerCase().indexOf('network') < 0){
gs.info(gr.number);
}
}
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2022 10:37 PM
Thank you @rohil. it worked out
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2022 06:40 AM
Try something like below.
var gr = new GlideRecord('incident');
gr.query();
while(gr.next()){
if(gr.getDisplayValue('assignment_group').toLowerCase().indexOf('network') < 0){
gs.info(gr.getDisplayValue('assignment_group'));
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2022 06:51 AM
hello,
Please use the below code:-
var gr = new GlideRecord('incident');
gr.addEncodedQuery('assignment_group.nameNOT LIKEnet')
gr.query(),
while(gr.next())
{
gs.info(gr.number);
}
Please mark my answer as correct based on Impact.