ServiceNow initialize vs newRecord | Servicenow tips and tricks | Sevicenow GlideRecord examples
TechnoMonk
Hi All,
Hope you are doing fine. In this tutorial we will be looking into a basic question on Servicenow glideRecord i.e. what is the difference between initialize and new record in servicenow. First we will try to understand what is Servicenow glideRecord ? The GlideRecord class is the way to interact with the ServiceNow database from a script. See the GlideRecord API reference for a complete list of methods.
GlideRecord interactions start with a database query. The generalized strategy is:
- Create a GlideRecord object for the table of interest.
- Build the query condition(s).
- Execute the query.
- Apply script logic to the records returned in the GlideRecord object.
Here is what the generalized strategy looks like in pseudo-code: // 1. Create an object to store rows from a table var myObj = new GlideRecord('table_name');
// 2. Build query myObj.addQuery('field_name','operator','value'); myObj.addQuery('field_name','operator','value');
// 3. Execute query myObj.query();
// 4. Process returned records
while(myObj.next()){
//Logic you want to execute.
//Use myObj.field_name to reference record fields
}
What is servicenow gliderecord initialize ? Creates an empty record within the current GlideRecord that is suitable for population before an insert.
What is servicenow gliderecord newRecord? Creates a GlideRecord, sets the default values for the fields, and assigns a unique ID to the record.
Hope you like this video , please like follow and subscribe to get notifications about new videos in future.
Regards, Amit Gujarathi (Technomonk) ... https://www.youtube.com/watch?v=RPJlcM_QTlc
37581942 Bytes