Posts

Showing posts from 2018

Use splice() instead of delete for arrays in JS

var words = ["Hello", "World", "and", "some", "random", "text"] console.log(words.length); // returns 6 delete words[2] console.log(words.length); // returns 6 Delete replaces the item with "undefined" instead of the removing it from the array The correct approach to remove an item from an array is to use "splice", The splice() method adds/removes items to/from an array, and returns the removed item(s) Syntax array.splice(index, howmany, item1, ....., itemX) var words = ["Hello", "World", "and", "some", "random", "text"] console.log(words.length); // returns 6 words.splice(2, 1) console.log(words.length); // returns 5

JQuery in ServiceNow

Image
In order to use jQuery in ServiceNow you need to use $j or $j_glide Note: You should avoid manipulating DOM in ServiceNow, Instead use GlideForm API

Find duplicate records in ServiceNow

Find duplicate records using GlideAggregate and groupBy var importGR = new GlideAggregate('u_import'); importGR.addAggregate('COUNT', 'u_number'); importGR.addNotNullQuery('u_number'); importGR.groupBy('u_number'); importGR.addHaving('COUNT', '>', 1); importGR.query(); while (importGR.next()) {   gs.log(importGR.u_number); }