Attachment appearing in the body of case and not header

rhyannagood
Tera Contributor

I understand that this is how it functions out of the box, but I have an attachment field on one of my record producers. Whenever someone uploads an attachment through the field, it places the attachment in the body of the record producer. I also noticed that the table name has "zz_yy" attached at the beginning. Is there any configuration I can implement to ensure the image is placed in the header instead of the body of the case?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@rhyannagood 

yes this is OOTB but you can use custom solution.

use this link where I shared solution on how to copy the attachment present in attachment variable to the target record so that it appears in header.

Disable ZZ_YY prefix from attachment when added through record producer 

Sharing the script here

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

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-1747066719012.png

 

2) The file present on the attachment variable

AnkurBawiskar_1-1747066719020.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

5 REPLIES 5

rhyannagood
Tera Contributor

Hi Ankur,

 

The BR did not work! I tested and the image still populates in the body of the case:

 

rhyannagood_0-1747072738873.pngrhyannagood_1-1747072756256.png