Additional comments and attachments are not being copied.

Community Alums
Not applicable
var change = new GlideRecord("change_request");
change.short_description = current.short_description;
change.description = current.description;
//change.cmdb_ci = current.cmdb_ci;
//change.priority = current.priority;
change.comments = current.comments.getJournalEntry(-1);
change.requested_by = current.caller_id;

//var c = current.comments.getJournalEntry(-1);
//change.comments.setJournalEntry(c);

var sysID = change.insert();

//current.rfc = sysID;
//var mySysID = current.update();
var attachment = new GlideSysAttachment();
var copiedAttachments = attachment.copy('incident', current.sysID, 'change_request', sysID);

gs.addInfoMessage("Change " + change.number + " created");
action.setRedirectURL(change);
action.setReturnURL(current);
9 REPLIES 9

Community Alums
Not applicable

script provided by you people should work. I think there is some other issue.

hi @Community Alums 

Please mark as Accepted Solution if this solves your query and HIT Helpful if you find my answer helped you. This will help other community mates too..:)

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @Community Alums ,

 

Your code is incorrect, Can you brief us on the requirement.

As i see you are inserting a new record which obviously have no attachement in it.


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Community Alums
Not applicable

creating a change request from incident record using UI Action

Sumanth16
Kilo Patron

Hi @Community Alums ,

 

Please refer to below thread:

https://www.servicenow.com/community/developer-forum/copy-attachments-from-one-record-to-another/m-p/2150848/page/3

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda