Regarding Glide Record method
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2025 06:41 AM - edited ‎08-05-2025 06:42 AM
Please clear a doubt.
I tried to insert a record in a table through initialize() method(Glide Record) , using Background Script.
The record was successfully inserted , but when I inserted it without using initialize() method, it was still created.
If we can create a record without initialize() method, then why do we use it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2025 07:45 PM - edited ‎08-05-2025 07:47 PM
hi @khuranahima
You don’t need initialize() if you are creating a new record and haven’t loaded any existing record.
Use initialize() when:
- You loaded an existing record with .get() or .query(), and now want to create a new record.
- You want to be safe and clear that you’re creating something new.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2025 08:02 PM
initialize() function is used to initialize the record which used for query before such as update and insert logical
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2025 08:29 PM
it's good practice to use initialize() method.
-> if you reuse a GlideRecord object in a script (such as in a loop or across multiple insert operations) and do not call initialize() between inserts, data you set previously may be unintentionally carried forward into subsequent records
-> This can lead to unintended data duplication or improper population of fields because the object may retain its prior values
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2025 12:27 AM
Thank you !