- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2016 01:18 PM
Hi all,
I was trying to bring all the list of one record to the new record in the same table,Similar to duplicating the record or insert ui action.
But was not able to bring the related lists.
Thanks and Regards,
Shariq
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2016 02:30 PM
Hi Sharique,
I had a similar requirement and worked on it just yesterday. I needed to have a 'Copy' button that creates an exact copy of the record with the created date and time appended to the name, this should also create copies of the records related list. (same records in related list should show up here too, i.e. copies of them)
If this is exactly the same as you want to do, you could use my UI action script modified to suit your instance.
copyFile();
function copyFile(){
current.u_name = current.u_name + " Copy_[" + gs.nowDateTime() + "]";
var originalID = current.sys_id + '';
var copyID = current.insert() + '';
if(copyID){
var gr = new GlideRecord('u_RelatedFile'); //replace table name with the table name of your related list
gr.addQuery('u_file', originalID); //replace field name with the reference field in your related list that points to the main table
gr.query();
while(gr.next()){
gr.u_file = copyID; //replace field name with the reference field in your related list that points to the main table
gr.insert();
}
}
}
P.S. Please hit like, helpful or Correct for my responses as they apply to you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2016 01:20 PM
Hi Sharique,
Can you please give example on what exactly you are trying to do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2016 02:09 PM
Hi Sharipque,
Do you want to create a UI action similar to "Insert" in order to copy child (related list) records as well as the parent record?
In this case, you need to modify the original script, and add GlideRecord query to copy all child records to new record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2016 02:30 PM
Hi Sharique,
I had a similar requirement and worked on it just yesterday. I needed to have a 'Copy' button that creates an exact copy of the record with the created date and time appended to the name, this should also create copies of the records related list. (same records in related list should show up here too, i.e. copies of them)
If this is exactly the same as you want to do, you could use my UI action script modified to suit your instance.
copyFile();
function copyFile(){
current.u_name = current.u_name + " Copy_[" + gs.nowDateTime() + "]";
var originalID = current.sys_id + '';
var copyID = current.insert() + '';
if(copyID){
var gr = new GlideRecord('u_RelatedFile'); //replace table name with the table name of your related list
gr.addQuery('u_file', originalID); //replace field name with the reference field in your related list that points to the main table
gr.query();
while(gr.next()){
gr.u_file = copyID; //replace field name with the reference field in your related list that points to the main table
gr.insert();
}
}
}
P.S. Please hit like, helpful or Correct for my responses as they apply to you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2022 04:33 AM
Hi How can I copy related list from one table to a different table