- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2019 06:49 AM
Hello,
I have a a table in scoped app which has 50+ columns.
For testing pursposes, I want to develop a UI action to copy an existing row all 50+ fields, copy all butcouple of fields from existing row like address fields, phone number etc, modify only a couple of them like first name, last name and insert it into the same table again.
Is there a short hand way of doing a deep copy of glide record?
e.g. if possible I dont want 50+ lines of snippet below...
grnew.address1=current.address1;
grnew.address2=current.address2;
...50 times...
grnew.firstname = "new First Name" + randomNumber
grnew.lastname = "New last Name" + randomNumber;
grnew.insert();
instead I would like ideally is something like below:
grnew = current.deepcopy();
grnew.firstname = "new First Name" + randomNumber
grnew.lastname = "New last Name" + randomNumber;
grnew.insert();
Any suggestions for an efficient way of doing this deep copy?
Solved! Go to Solution.
- Labels:
-
Scoped App Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2019 07:35 AM
This should help you. you can create another glide record to insert. Let me know if you need that code as well
var gr = new GlideRecord('incident');
gr.addQuery('number','INCPA0013565');
gr.query();
gs.info(gr.getRowCount());
if (gr.next()) {
for(var variable in gr) {
gs.info(variable);
gs.info(gr.getValue(variable));
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2019 07:35 AM
This should help you. you can create another glide record to insert. Let me know if you need that code as well
var gr = new GlideRecord('incident');
gr.addQuery('number','INCPA0013565');
gr.query();
gs.info(gr.getRowCount());
if (gr.next()) {
for(var variable in gr) {
gs.info(variable);
gs.info(gr.getValue(variable));
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2019 07:36 AM
If the properties are the same you can just do a for in loop;
for (prop in current){
grnew.setValue(prop, current.getValue(prop);
}
grnew.insert()