- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2017 11:03 AM
I would like to duplicate a record before further processing it but I don't want to create it by hand identifying each field name and copying it over. Instead, I would like to iterate through all the items.
In non-scoped apps you can use getFields function to perform this task but this is not available in scoped apps. How does one go about looking into the code of such script?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2017 11:12 AM
Hi Verda,
you could try this simple trick - no worries...there is a new sys_id generated upon insert.
the examle uses the incident table
var t = new GlideRecord("incident");
t.get(" [your sys_id here] ");
t.insert();
Kind regards
Sebastian

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2017 11:12 AM
Hi Verda,
you could try this simple trick - no worries...there is a new sys_id generated upon insert.
the examle uses the incident table
var t = new GlideRecord("incident");
t.get(" [your sys_id here] ");
t.insert();
Kind regards
Sebastian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2017 11:15 AM
Is the sys_id on the second line the id of the record from which I will copy all fields?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2017 11:28 AM
Works great:
var gr = new GlideRecord('myTableName');
gr.initialize();
gr.get(current.sys_id);
gr.insert();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2017 11:38 AM
When you say duplicate do you want to duplicate the record number too?