Posts

Showing posts from April, 2024

Arrays

// Single Array - Push single values into an array.  // If there is a field which doenst have a single value but comma seperated values then split it and adds it to the arra y var x = 0; var st = ''; var ar = new Array(); var gr = new GlideRecord('cmdb_ci_service'); gr.addEncodedQuery("u_search_tagsISNOTEMPTY"); gr.query(); while (gr.next()) {   x++;   // gs.print(x + "  " + gr.u_search_tags);  // e.g.  Azure, Joe, Harry, OR Azure   st = gr.u_search_tags;   st = st.replace(/,\s*$/, ""); // Remove the last comma and any spaces if there are any   // Does it have a comma   if (st.indexOf(',') != -1) {     var sts = st.split(',');     for (var i = 0; i < sts.length; i++) {       //gs.print("----  " + x + "  --" + i + "  --" + sts.length + "  " + sts[i]); e..g        ar.push(sts[i]);       if (sts.length - 1 != i) {         x++; ...