Categories:
  1. ServiceNow Application Developer
  2. ServiceNow Scripting Objects
  3. ServiceNow Scripting API
  4. GlideRecord – Create, Read
  5. GlideRecord – Update & Delete
  6. Popular ServiceNow API Methods
  7. UI Action – Server Side & Client Side
  8. UI Policy
  9. Client Script – OnLoad
  10. Client Script – OnChange
  11. Client Script – onSubmit
  12. Scripting Best Practices
  13. Client Script Best Practice
  14. Client Script Requirement
  15. Business Rule Requirments
  16. Inbound Action
  17. Requirement Sheet
  18. Only Admin should be able to see Resolution Information tab
  19. From P3 & P4 user can’t derectly set to P1 but from P2 they can set P1
  20. Directly P1 Incident can’t be created
  21. Child Incident should close once parent Problem close
  22. Populate list type of fields in servicenow in Incident Form
  23. For Critical Priority, font will be bold and background will be red
  24. Create a field on Incident form called Expected Data, if incident move to Pending this date will be add 7 days from current date

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

Total Views: 1265

No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *