First lets take a look into Server-side Glide classes
1. GlideRecord: This Class used for database operations instead of writing SQL queries. GlideRecord is a special Java class that can be used in JavaScript exactly as if it were a native JavaScript class. A GlideRecord is an object that contains records from a single table.
var inc = new GlideRecord('incident'); inc.addActiveQuery (); inc.query ();
2. GlideElement: This class will be used to operate on the fields of the current GlideRecord.
var inc = new GlideRecord('incident'); inc.addActiveQuery (); inc.query (); if(inc.next()) inc.short_description.canRead ();//check to see if the current user is allowed to read the record
3. GlideSystem: This class will be used to get information about the system.
gs.addInfoMessage ('Incident has been successfully submitted!!');
4. GlideAggregate: This class will be used to perform database aggregation queries, such COUNT, SUM, MIN, MAX, and AVG.
var inc = new GlideAggregate ('incident'); inc.addQuery ('category', software'); inc.setGroup (false); inc.addAggregate ('COUNT', 'sys_mod_count'); Inc. Query (); If (Inc. Next ()) { gs.info ('COUNT: ' + inc.getAggregate ('COUNT', 'sys_mod_count')); }
5. GlideDateTime: This class will be used to perform date-time operations, such as date-time calculations, formatting a date-time, or converting between date-time formats.
var gdt = new GlideDateTime ("2011-08-31 08:00:00"); var gtime1 = new GlideTime(); gtime1.setValue ("00:00:20"); gdt.add (gtime1); var gtime2 = gdt.getTime(); gs.info (gtime2.getByFormat ('hh:mm:ss'));
Now lets see Client-side Glide classes
1. GlideAjax: This class will be used to execute server-side code from the client.
var ga = new GlideAjax('HelloWorld'); // HelloWorld is the script include class ga.addParam('sysparm_name','helloWorld'); // helloWorld is the script include method ga.addParam('sysparm_user_name',"Bob"); // Set parameter sysparm_user_name to 'Bob' ga.getXML(HelloWorldParse); /* Call elloWorld.helloWorld() with the parameter sysparm_user_name set to 'Bob' and use the callback function HelloWorldParse() to return the result when ready */ // the callback function for returning the result from the server-side code function HelloWorldParse(response) { var answer = response.responseXML.documentElement.getAttribute("answer"); alert(answer); }
2. GlideDialogWindow: This class will be used to display a dialog window.
var gdw = new GlideDialogWindow('ui_page'); // gdw.setTitle ('Test'); gdw.setSize (500,300); gdw.adjustBodySize (); gdw.render ();
3. GlideForm: This class will be used to customize forms.
g_form.setValue ('short_description', 'replace this with appropriate text');
4. GlideList2: This class will be used to customize (v2) lists, including normal lists and related lists.
g_list.addfilter ("active=true");
5. GlideMenu: This class will be used to customize UI Context Menu items.
g_menu.clearImage (g_item); // Specifies the item to have its image removed from display.
6. GlideUser: This class will be used to get session information about the current user and current user roles.
Var isItil = g_user.hasRole ('itil');