- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2021 04:06 AM
So I am trying to create a copy of a record by clicking on a UI Action. Now the problem is I don't know that how I can copy the Variable editor data from that request to the copied request.
Any help would be appreciated 🙂
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2021 05:58 AM
Hi,
this worked well for me
please enhance it further
var gr = new GlideRecord('incident');
gr.get('4dcd5214070b20102011ff208c1ed020'); // older record with variables
// create new record
var rec = new GlideRecord('incident');
rec.initialize();
rec.insert();
// then iterate for question_answer and insert the variable
var question = new GlideRecord('question_answer');
question.addQuery('table_sys_id', gr.sys_id);
question.query();
while(question.next()){
var att = new GlideRecord('question_answer');
att.initialize();
att.table_sys_id = rec.sys_id;
att.table_name = question.table_name;
att.question = question.question;
att.order = question.order;
att.value = question.value;
att.insert();
}
gs.info(rec.number);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2021 05:28 AM
Though im able to see the data when im using info message on the variable.toString().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2021 05:34 AM
Hi,
can you run the script in background script and test if it works for that
please share the script you are using
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2021 05:58 AM
Hi,
this worked well for me
please enhance it further
var gr = new GlideRecord('incident');
gr.get('4dcd5214070b20102011ff208c1ed020'); // older record with variables
// create new record
var rec = new GlideRecord('incident');
rec.initialize();
rec.insert();
// then iterate for question_answer and insert the variable
var question = new GlideRecord('question_answer');
question.addQuery('table_sys_id', gr.sys_id);
question.query();
while(question.next()){
var att = new GlideRecord('question_answer');
att.initialize();
att.table_sys_id = rec.sys_id;
att.table_name = question.table_name;
att.question = question.question;
att.order = question.order;
att.value = question.value;
att.insert();
}
gs.info(rec.number);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2021 09:45 AM
Hope you are doing good.
Did my reply answer your question?
If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.
Thanks!
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2021 01:58 AM
Wait Ankur let me test this out. I will reply to you in a day or two
Regards,
Arsh