attachment is not copied when i click on copy change option in case of normal change(change management).

Nikita Singh
Giga Expert

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.

find_real_file.png

Pls help

1 ACCEPTED SOLUTION

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

9 REPLIES 9

Hi Ankur,

 

Any idea how can I add the related list when copying a change aside from the Affected CI?

 

Your help will be much appreciated, Thanks in advance!

Hi,

you want to create record in related list table of affected CI? Didn't get the requirement though

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

 

Not the Affected CI, I have other table on my related list that I want to be copied over when copying the change.

find_real_file.png

Those tables inside the red box is what I want to be copied when copying a change. These are all under related list.

Let me know if you have any idea how to copy those records. 

Thank you in advance, your help is much appreciated. 

@Nikita Singh 

Is this answered?

if my answer helped you, kindly mark it as Correct & 👍Helpful so that it does not appear in unanswered list & close the thread.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

rahulyamgar
Tera Guru

Hello Ankur,

But property was set to copy the attachment from the original change, then why do we need to make customization? I understand that the code which you explored lacks the copy attachment functionality, should it be brought to the ServiceNow`s attention.

Thanks,

Rahul