Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

Background script for printing the INC no.'s that ends with 0(zero)

amit71
Tera Contributor

Background script for printing the INC no.'s  that ends with 0(zero). Please guide this how to achieve.

eg: INC1234430

1 ACCEPTED SOLUTION

Ricky S Larsson
Kilo Sage

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);
}

View solution in original post

10 REPLIES 10

That's correct. Performance wise it would be better to use conditions in the query though, which you are hinting at.