deal with leading / trailing spaces

var ciclass='u_cmdb_ci_laptops';
//ciclass='u_smart_devices';

var querytorun='nameISNOTEMPTY^install_status!=14';
//var querytorun='nameISEMPTY';
var gr=new GlideRecord(ciclass);
gr.addQuery(querytorun);
gr.query();
while (gr.next()){
if (startsOrEndsWithWhitespace(gr.name)){
//if (startsOrEndsWithWhitespace(gr.sys_id)){//--for empty name query
gs.print(gr.name);
//gs.print(gr.sys_id); //--for empty name query
}
}



function startsOrEndsWithWhitespace(str){
return /^\s|\s$/.test(str);
}

Comments

Popular posts from this blog

Running transform maps asynchronously

Post a command to the ECC queue for the mid server to initiate a powershell file copy

GlideRecord setValue