- 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
‎02-23-2022 11:36 PM
Hello
I know it's a bit late but I hope this help!
https://community.servicenow.com/community?id=community_question&sys_id=915e4feddb9cdbc01dcaf3231f961960