Worknotes need to be added to task when attachement was added to ritm or request

Ak8977
Tera Expert

when we add an attachment to a RITM or request, then in the task  a worknotes to be added stating that 'xyz' attachment was added to request or ritm. Can someone help me on this.
thanks,

3 REPLIES 3

RAMANA MURTHY G
Mega Sage
Mega Sage

Hello @Ak8977 ,

You can write After insert business rule on sys_attachment table. Please find the below sample script and screen shots

 

(function executeRule(current, previous /*null when async*/) {
	if(current.table_name == 'sc_req_item'){    
		var ritmSysId = current.table_sys_id;     // RITM record's sys_id
		var gr = new GlideRecord('sc_req_item');
		gr.addQuery('sys_id',ritmSysId);
		gr.query();
		if(gr.next()){
			gr.work_notes = current.file_name + " attachment added to "+gr.number;
			gr.update();
		}
	}
})(current, previous);

 

 

 

Screenshot_20240212-093711.png

 

Screenshot_20240212-093837 (1).png

 

You can customize the script according to your requirement,

 

Please mark my answer helpful & correct, if it helps you

Thank you

 

 

Please mark my answer helpful ļ‘ & correct āœ… if it helps you
Thank you

G Ramana Murthy
ServiceNow Developer

I want to update the worknotes in task when attachment is added to request or ritm.
Not to update the worknotes in ritm

Hello @Ak8977 ,

Then you can glide sc_task table with the RITM sys_id, you can change above script according to your requirement.

 

Please mark my answer helpful & correct, if it helps you

Thank you

 

 

Please mark my answer helpful ļ‘ & correct āœ… if it helps you
Thank you

G Ramana Murthy
ServiceNow Developer