How to copy attachments from RITM to Incident

kutvaram
Tera Expert

I have used the following script in BR after insert :

GlideSysAttachment.copy("sc_req_item", current.request_item.sys_id, "incident", current.sys_id);

But it is not working.

Please do the needful.

Regards,
Ram Prakash

1 ACCEPTED SOLUTION

Thank you. That indicates that the incident is using the parent field to point to the RITM record. In that case, your business rule should be able to copy the attachment from the RITM to the incident record using the copy command I gave earlier if everything else is working properly.



GlideSysAttachment.copy("sc_req_item", current.parent, "incident", current.sys_id);



If not, please use the business rule debugger to ensure your business rule is triggering, or debug statements in your UI action (if that is how you are copying the file.) You may also find this video helpful for debugging:



Faster Server Side Script Development and Test


View solution in original post

16 REPLIES 16

Thank you Ram. We're getting somewhere now. I'll assume the workflow is running on the Requested item table. If not, let me know.



Does the incident have a value in the parent field?



If not, update the workflow activity that creates the task to set the parent field such as:



task.parent = current.sys_id;



That will relate the requested item to the incident and your script would then become:



GlideSysAttachment.copy("sc_req_item", current.parent, "incident", current.sys_id);



Note: This will not work if the value of the parent field is not pointing to the requested item task record!!!


Hello Chuck,



This is also not working



Regards,


Ram


Hi Ram,



I am sorry this is not working. It was not meant to be a solution until I find out more. You have not answered my previous questions. Until then I am only guessing at what is the problem.



How are the incident and requested item related at the table/field level?


Hello Chuck,



In RITM Table, Incident is present as a related list.



But I dont find any related field in Incident Table for RITM.



Regards,


Ram


Thank you Ram. That's a step in the right direction. The next step is to understand which field on the incident table is being used to relate incident to RITM. Can you include a screen shot of that requested item? The breadcrums (blue filter text) will tell me more.