- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2020 03:02 PM
I find script includes to generate initialize() automatically and read that it is called as constructor when you create script include the object with a new operator.
Is it not the same for creating new GlideRecord? As initialize() being called for only inserts, I wonder if GlideRecord does not follow the framework being used for script includes and instantiation of this object does not call initialize() automatically.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2020 03:34 PM
A bit of speculation below but it seems to make sense.
JS didn't add classes with inheritance until ES6 so ServiceNow needed to make their own standardised way of simulating class like behavior. One of the features of a class is a constructor to initialize an object but as they didn't have that they made their own called "initialize".
This is completely different in functionality to the GlideRecord "initialize" but as they conceptually do a similar thing they ended up with the same name.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2020 11:42 PM
Hello Giri
I hope you know that GlideRecord's initialize method is used to dynamically create a record in the ServiceNow table.
Let's create record in Incident Table.
var record_creation=new GlideRecord('incident');
record_creation.initialize();
record_creation.setValue('short_description','Hello');
record_creation.insert();
This is how you basscially create record.
Just for best practice. always use new record instead of initialize as new record created record with default values.
Please Mark it helpful/correct if my answer helps in any way to resolve your query.
Reach out to me if any more help required.
Regards
Yash.K.Agrawal