- 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-13-2022 03:34 AM
Hi sample script
var query = 'numberENDSWITH0'; //ends with 0
var inc = new GlideRecord('incident');
inc.addEncodedQuery(query);
inc.query();
while(inc.next())
{
gs.info("INC"+inc.number);
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2022 12:43 AM
Hi
Can you suggest script without using the addEncodedQuery().
Thanks,
Amit

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2022 01:09 AM
Try the below without encoded query
var inc = new GlideRecord('incident');
inc.addQuery("number",'ENDSWITH',0);
inc.query();
while(inc.next())
{
gs.info("INC"+inc.number);
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2022 03:36 AM