- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2020 03:15 AM
Hi Community,
I need help in filtering the records , which does not starts with in addQuery() method. How can we achieve this?
Any help would be greatly appreciated.
Thanks,
Pihu
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2020 03:52 AM
Hi,
Sample below
var arr = [];
var rec = new GlideRecord('incident');
rec.query();
while(rec.next()){
var startsWith = rec.caller_id.name.startsWith('AB'); // this will give false when doesn not starts with
if(startsWith.toString() == 'false'){
arr.push(rec.number.toString());
}
}
gs.info('Incidents where caller name does not start with AB'+ arr);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2020 03:27 AM
Hi,
doesn not starts with is not available as filter operator
So you will have to determine the condition by iterating the records using while loop
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2020 03:33 AM
Thanks Ankur.
Can you please help with the condition - Server name does not starts with A0 or A1.
Thanks,
Pihu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2020 03:52 AM
Hi,
Sample below
var arr = [];
var rec = new GlideRecord('incident');
rec.query();
while(rec.next()){
var startsWith = rec.caller_id.name.startsWith('AB'); // this will give false when doesn not starts with
if(startsWith.toString() == 'false'){
arr.push(rec.number.toString());
}
}
gs.info('Incidents where caller name does not start with AB'+ arr);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2020 08:46 AM
Thanks! Ankur.It worked for me.