As a ServiceNow developer, we should know how to create, Update, Read & Delete Operations in ServiceNow.
To do that we should use ServiceNow GlideRecord Method.
How can you Insert a record in Incident table :
var gr = new GlideRecord('incident'); gr.initialize(); gr.short_description = "Test Insert"; gr.caller_id = "71826bf03710200044e0bfc8bcbe5d3b"; gr.insert(); gs.info('Incident Number '+gr.number+' - '+gr.state.getDisplayValue());
How can you read a record in Incident table :
var gr = new GlideRecord('incident'); if(gr.get('number','INC0010075')){ gs.info(gr.description+' '+gr.state.getDisplayValue()+' '+gr.assignment_group.getDisplayValue()); }else{ gs.info('Record Not found'); }
How Can you read list of record in Incident table :
var gr = new GlideRecord('incident'); gr.addEncodedQuery('state=2^priority=2'); //gr.addQuery('state',2); // In Progress Incident //gr.addQuery('priority',2); gr.query(); gs.info('Record Count '+gr.getRowCount()); while(gr.next()){ gs.info(gr.number+' '+gr.short_description); }
Youtube Link: https://youtu.be/mssfoXfIe0I
No responses yet