- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2022 03:32 AM
Background script for printing the INC no.'s that ends with 0(zero). Please guide this how to achieve.
eg: INC1234430
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2022 01:16 AM
You could achieve this after the query as well by using the regex test function
var gr = new GlideRecord('incident');
var regex = /[0]$/;
gr.query();
while(gr.next()){
var endsWithZero = regex.test(gr.number);
if(endsWithZero)
gs.print(gr.number);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2022 12:42 AM
Hello
Is is possible to execute without using addEncodedQuery().
Thanks,
Amit

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2022 12:44 AM
You can try
addQuery('number', 'ENDSWITH', '0');
instead of
addEncodedQuery();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2022 02:18 AM
Hi,
any reason you don't want to use addEncodedQuery()?
yes it's possible as mentioned by Jaspal
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
‎07-14-2022 01:16 AM
You could achieve this after the query as well by using the regex test function
var gr = new GlideRecord('incident');
var regex = /[0]$/;
gr.query();
while(gr.next()){
var endsWithZero = regex.test(gr.number);
if(endsWithZero)
gs.print(gr.number);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 02:32 AM
Hi Richard,
running the GlideRecord.query() without any condition will fetch all records from the DB.
Then you are applying the regex ,