How to add attachment variable on header on the request form instead of updating in work notes

Are Kaveri
Tera Contributor

Hi ,

 

I have below requirement. 
one of our clients asked to add a variable on my record producer form.

if end user attaches any attachment and submit the request. It is updating in worknotes or activity log but not on the header.

my requirement is whenever end users add any attachment he should be able to see on the request form header itself .

 

can someone help me how to add it on header of the request form instead of adding in activity log.

1 ACCEPTED SOLUTION

@Are Kaveri 

you didn't mention that in your question.

For that you need to use while loop in script

(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();
	while (gr.next()) {
		gr.table_name = current.getTableName();
		gr.update();
		new global.VariableUtil().copyAttachment(gr.sys_id, current.getTableName(), current.sys_id); 
	}

})(current, previous);

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

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

@Are Kaveri 

so basically you want to copy the file from that attachment variable and add it to the header where normal attachments are shown?

If yes then below link has solution shared by me; enhance it further as per your requirement

Disable ZZ_YY prefix from attachment when added through record producer 

Please ensure you update this line as the function has changed from copy to copyAttachment()

		new global.VariableUtil().copyAttachment(gr.sys_id, current.getTableName(), current.sys_id); 

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

@Ankur Bawiskar  @Uday Soni05  

I tried below post for my requirement. the attachment added in variable of type attachment was getting under activity log but not on the header.

Am i missing something.

AreKaveri_1-1697737600804.png

 

AreKaveri_0-1697737571738.png

 

 

@Are Kaveri 

You didn't copy the exact script.

Update your this line

gr.addQuery("table_name", "ZZ_YY" + current.getTableName());

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

@Ankur Bawiskar ,

there are 3 attachment variables on my form. when i attach the attachments only one attachment was coming on the header on my target record. 

 

Is there any restrictions for attachment variable count?