- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2016 04:11 AM
Basically what the title says. What's the difference between those two functions?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2016 04:15 AM - edited ‎06-29-2023 07:27 AM
Hi Peter,
Per the wiki...
- initialize(): Creates an empty record suitable for population before an insert.
- newRecord(); Creates a GlideRecord, set the default values for the fields and assign a unique id to the record.
Try these two in scripts background and you'll see that initialize gives no value to opened_at, whereas newRecord does.
var inc = new GlideRecord('incident');
inc.initialize();
gs.print(inc.opened_at.getDisplayValue());
var inc = new GlideRecord('incident');
inc.newRecord();
gs.print(inc.opened_at.getDisplayValue());
I have always trusted newRecord more since learning about this a few years ago.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2017 06:26 PM
Chuck, do you have a video using newrecord() in a widget?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2017 05:59 AM
Hi Tim,
We covered initialize() vs. newRecord() on ep 29 of TechNow. There's no reason it shouldn't work in the server script of a widget.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2017 06:20 AM
Thank you sir. I thought I remembered hearing this explained, but could not find it in the 100+(exaggeration) videos I watched on Service Portal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2018 12:09 PM
Thank you for the elaborated response Chuck! It was helpful.
Regards,
Hitesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2018 05:05 AM
You are welcome. Thank you for using the community!
