Attachment variable is not attaching the attachment o the case.

Kachu
Kilo Sage

Hi Community, I have Created a  attachment variable  on the record producer. Ant that task is submitted by the to-do task. i.e "Submit Catalog item". But when the attachment is added that attachment is not showing on the HR case.

I have mapped the field with "File_attachmnet " field type on HR case. i also tried to add code on record producer to copu the attachment. But its not working can any one help me with this ?

var gr = new GlideRecord('sys_attachment');
if(gr.get(producer.attach_covid_report)){ //attachment field name
	gr.table_name='HR Employee Relations';     //copy to table name
	gr.table_sys_id=current.sys_id;//copy to record sys_id
	gr.insert();

 

1 ACCEPTED SOLUTION

I was able to resolve this by  adding a widget and on submit client script . thank you verymuch

View solution in original post

6 REPLIES 6

Gaurav Banga
Kilo Guru

Ankur Bawiskar
Tera Patron
Tera Patron

@Kachu 

It won't work directly using map to field

I have shared working solution here

just enhance as per your requirement

https://community.servicenow.com/community?id=community_question&sys_id=41af7501db1ea010fa192183ca96...

Regards
Ankur

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

Gaurav Banga
Kilo Guru

I tried with your code and it works for me with some correction.

1. Correct the table name from label 'HR Employee Relations' to actual case table name.
var gr = new GlideRecord('sys_attachment');
if(gr.get(producer.u_attachment)){ //attachment field name
gr.table_name='sn_hr_core_case_operations'; //copy to table name
gr.table_sys_id=current.sys_id;//copy to record sys_id
gr.insert();
}

2. Check the attachment table application access settings are configured as below.

find_real_file.png

3. Run as background script to clear table cache:

GlideTableManager.invalidateTable('sys_attachment');
 
 
Thanks,
Gaurav

I was able to resolve this by  adding a widget and on submit client script . thank you verymuch