will the attachment be carried to the Catalog task whatever I attached in the catalog item?

divyadhanda
Tera Contributor

I have an attachment and i have added via catalog item view and it s available in the RITM after creating a request, but it s not present in the Sctask. How can i bring in Sctask ?

2 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron
Tera Patron

@divyadhanda 

you can use after insert business rule on sc_task to copy attachment from RITM to SC Task

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

    new GlideSysAttachment().copy('sc_req_item', current.request_item, 'sc_task', current.sys_id);

})(current, previous);

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

View solution in original post

Sarthak Kashyap
Kilo Sage

Hi @divyadhanda ,

 

I tried your problem in my PDI and it is working fine for me please create one OnBefore Business Rule which works when sc_task inserted and add below script 

 

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

	// Add your code here
	var ritmId = current.request_item;

    var att = new GlideRecord('sys_attachment');
    att.addQuery('table_sys_id', ritmId);
    att.addQuery('table_name', 'sc_req_item');
    att.query();

    while (att.next()) {
        GlideSysAttachment.copy('sc_req_item', ritmId, 'sc_task', current.sys_id);
    }

})(current, previous);

 

SarthakKashyap_0-1761917384985.png

SarthakKashyap_1-1761917403354.png

 

Result: 

RITM have attachment

SarthakKashyap_2-1761917428831.png

Same attachment got attached to sc_task

SarthakKashyap_3-1761917460607.png

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards,

Sarthak

 

 

 

View solution in original post

12 REPLIES 12

Ankur Bawiskar
Tera Patron
Tera Patron

@divyadhanda 

you can use after insert business rule on sc_task to copy attachment from RITM to SC Task

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

    new GlideSysAttachment().copy('sc_req_item', current.request_item, 'sc_task', current.sys_id);

})(current, previous);

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Can we use Before insert BR or After insert BR?

@divyadhanda 

after insert

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Can we do this catalog item specific? Only for a particular catalog item, this BR should get execute.