- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2019 12:45 AM
Hi,
Attachment is not getting copied along with other fields when i am clicking on copy change option in case of normal change(change management). Even i have ticked enable copy change feature but still it's not working.
Pls help
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2019 05:37 AM
Hi Nikita,
in the out of the box Copy Change UI action it is calling a script include ChangeUtils
below is the out of the box code
function OnCopyChangeClick() {
function addParam(form, name, val) {
var inp = cel('textarea', form);
inp.name = name;
inp.value = val;
}
var srcSysId = g_form.getUniqueValue(); // this is the source record sys_id
var ga = new GlideAjax('ChangeUtils');
ga.addParam('sysparm_name', 'getChangeQueryParams');
ga.addParam('sysparm_src_sysid', srcSysId);
ga.setWantSessionMessages(true);
ga.getXMLAnswer(function (queryParam) {
if (queryParam) {
var gotoURL = new GlideURL('CopyChangeRelatedLists.do');
gotoURL.setEncode(false);
gotoURL.addToken();
gotoURL.addParam('srcSysID', srcSysId);
gotoURL.addParam('newSysID', '$sys_id'); // this is the new target record sys_id
gotoURL.addParam('sysparm_returned_action', '$action');
var form = cel('form', document.body);
hide(form);
form.method = "POST";
form.action = g_form.getTableName() + ".do";
if (typeof g_ck != 'undefined' && g_ck != "")
addParam(form, 'sysparm_ck', g_ck);
addParam(form, 'sys_id', '-1');
addParam(form, 'sysparm_query', queryParam);
addParam(form, 'sysparm_goto_url', gotoURL.getURL());
form.submit();
}
});
}
just check when new change is created as copy of older; does it fill the parent field with the old change number
if yes then have after insert BR on change request with condition as parent is not empty
GlideSysAttachment.copy('change_request', current.parent, 'change_request', current.sys_id);
what it will do is copy attachments from parent record to new record
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
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
09-19-2019 01:01 AM
Hi
In the UI Action try adding this line -
GlideSysAttachment.copy('change_request', chgID, 'change_request', newChange.sys_id);
Hope this helps
Regards,
Omkar Mone
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2019 01:05 AM
Hi,
Check whether in that UI action you have code for copy attachment?
I don't think it exist out of the box
check the UI action code and put this code below
GlideSysAttachment.copy('change_request', current.sys_id , 'change_request', newSysId);
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
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
09-19-2019 05:30 AM
Hi Ankur,
Thanks for your reply but it's still not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2019 05:37 AM
Hi Nikita,
in the out of the box Copy Change UI action it is calling a script include ChangeUtils
below is the out of the box code
function OnCopyChangeClick() {
function addParam(form, name, val) {
var inp = cel('textarea', form);
inp.name = name;
inp.value = val;
}
var srcSysId = g_form.getUniqueValue(); // this is the source record sys_id
var ga = new GlideAjax('ChangeUtils');
ga.addParam('sysparm_name', 'getChangeQueryParams');
ga.addParam('sysparm_src_sysid', srcSysId);
ga.setWantSessionMessages(true);
ga.getXMLAnswer(function (queryParam) {
if (queryParam) {
var gotoURL = new GlideURL('CopyChangeRelatedLists.do');
gotoURL.setEncode(false);
gotoURL.addToken();
gotoURL.addParam('srcSysID', srcSysId);
gotoURL.addParam('newSysID', '$sys_id'); // this is the new target record sys_id
gotoURL.addParam('sysparm_returned_action', '$action');
var form = cel('form', document.body);
hide(form);
form.method = "POST";
form.action = g_form.getTableName() + ".do";
if (typeof g_ck != 'undefined' && g_ck != "")
addParam(form, 'sysparm_ck', g_ck);
addParam(form, 'sys_id', '-1');
addParam(form, 'sysparm_query', queryParam);
addParam(form, 'sysparm_goto_url', gotoURL.getURL());
form.submit();
}
});
}
just check when new change is created as copy of older; does it fill the parent field with the old change number
if yes then have after insert BR on change request with condition as parent is not empty
GlideSysAttachment.copy('change_request', current.parent, 'change_request', current.sys_id);
what it will do is copy attachments from parent record to new record
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader