- 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 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 10:50 PM
Hello Giri,
GlideRecord initialize generally makes your object to be ready for new insertion. It will reset any data in that object and will be ready to accept new values for insertion.
It is different from SI initialize function. In SI, you set things which are required to be available before any other SI functions are called such as constants or setting value in any variables, then those are handled in the initialize function.
Mark the comment as helpful if it helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2020 11:09 PM
Hello Giri,
Also adding few more related articles which can help your answer.
https://community.servicenow.com/community?id=community_question&sys_id=639a072ddb5cdbc01dcaf3231f9619ae
https://community.servicenow.com/community?id=community_question&sys_id=744608a4db17bb405129a851ca9619a6
Please Mark as ✅ Correct if this solves your issue and also mark ???? Helpful if it helps resolve your problem.
Thanks,
Saji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2020 11:22 PM
Hi Giri,
initialize(): Creates an empty record suitable for population before an insert.
SI initialize function:The initialize function is automatically invoked when JavaScript objects are instantiated from the Script Include. Any variable defined as part of the this object in the initialize function is known to all other functions in the Script Include.
Kindly mark it as helpful and correct, if applicable.
Thanks and Regards,
Vishakha Pradhan