Attachment not getting attached in email

Hafsa1
Mega Sage

I have RP created for CSM table, where i have used some "attachment" type variables.

when submitting case with attachments, attached using "attachment" variables, they are not populating on top of the case. Rather they are seen in activity stream.

My issue is, I have simple notification created and "include attachment" is checked but still attachments are not getting on email. even in email log it is not attached. where can be the issue?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Hafsa1 

attachment from attachment variable is not automatically copied to the target record

check solution here which I shared for this and it should copy the file to target record

Disable ZZ_YY prefix from attachment when added through record producer 

sharing the solution again here

1) I created Async After Insert BR on the target table

2) Script as this

a) Remove the ZZ_YY

b) Then use the Copy Attachment

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

	// Add your code here
	var gr = new GlideRecord("sys_attachment");
	gr.addQuery("table_name", "ZZ_YY" + current.getTableName());
	gr.addQuery("table_sys_id", current.sys_id);
	gr.query();
	if (gr.next()) {
		gr.table_name = current.getTableName();
		gr.update();
		new global.VariableUtil().copyAttachment(gr.sys_id, current.getTableName(), current.sys_id); 
	}

})(current, previous);

Output:

1) The file added to the record

AnkurBawiskar_0-1737032717111.png

 

2) The file present on the attachment variable

AnkurBawiskar_1-1737032716772.png

 

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

12 REPLIES 12

Mark Manders
Mega Patron

Did you check the attachment table to validate that they are on the correct record? 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Ankur Bawiskar
Tera Patron
Tera Patron

@Hafsa1 

attachment from attachment variable is not automatically copied to the target record

check solution here which I shared for this and it should copy the file to target record

Disable ZZ_YY prefix from attachment when added through record producer 

sharing the solution again here

1) I created Async After Insert BR on the target table

2) Script as this

a) Remove the ZZ_YY

b) Then use the Copy Attachment

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

	// Add your code here
	var gr = new GlideRecord("sys_attachment");
	gr.addQuery("table_name", "ZZ_YY" + current.getTableName());
	gr.addQuery("table_sys_id", current.sys_id);
	gr.query();
	if (gr.next()) {
		gr.table_name = current.getTableName();
		gr.update();
		new global.VariableUtil().copyAttachment(gr.sys_id, current.getTableName(), current.sys_id); 
	}

})(current, previous);

Output:

1) The file added to the record

AnkurBawiskar_0-1737032717111.png

 

2) The file present on the attachment variable

AnkurBawiskar_1-1737032716772.png

 

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hafsa1
Mega Sage

notification I have written on sysapproval table but need attachment from sn_customerserservice table

That is information that is not in your question. You need to copy the attachments to the approval record to include them in the email. You can do that from the same code/(work)flow in which the approval record is created.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark