The CreatorCon Call for Content is officially open! Get started here.

How to copy the RITM's attachment to SC task

VIKAS MISHRA
Tera Contributor

Kindly check the below mentioned requirement and please suggest how to achive this.

 

Attachment should only be copied to those task where assignemnt group of task is "Ultima". means there could be some task where assignemnt group is alrready "ulmita" and some task might be assignment to ultima by helpdesk gruoup

 

1) While raising the request from portal user can add the attachment and that attachment would be visible on ritm form so we want that attachment to be copied to sc task also but when task gets created approval approval if any.

2) User can go to portal and add the attachment to already raised request so that attahment should also be copied to sc task. 

3) Duplicate attachment should not be copied to task otherwise it will run in loop.

 

If this can be done though script then please share the script.

3 REPLIES 3

Samaksh Wani
Giga Sage

Hello @VIKAS MISHRA 

 

Kindly check the link below :-

 

https://www.servicenow.com/community/now-platform-forum/copy-attachment-from-ritm-to-sc-task-on-requ...

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Regards,

Samaksh

piyushsain
Tera Guru

Hi,

Please create a insert BR on sys_attachment table

in the table use the code. PFA screenshots

piyushsain_0-1690465723350.pngpiyushsain_1-1690465748311.png

(function executeRule(current, previous /*null when async*/ ) {

    var ritm = new GlideRecord('sc_req_item');
    ritm.get(current.table_sys_id);

    if (ritm.assignment_group == 'Ultima') {
        var scTask = new GlideRecord('sc_task');
        scTask.addQuery('parent', current.table_sys_id);
        scTask.query();
        while (scTask.next()) {
            GlideSysAttachment.copy('sc_req_item', ritm.sys_id, 'sc_task', scTask.sys_id);
        }
    }

})(current, previous);

 

Please let me know if any issue. 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
Piyush Sain

@VIKAS MISHRA If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
Piyush Sain