Get attachment file name

Shuang
Tera Contributor

Hi Everyone,

I'm trying to get the attachment file name in a ticket, and write the file name into the worknote area.

I write my code as below.

I can file the attachment recoed,but don't know how to get the file name in that record.
Hope someone can help me to solve this problem.

Thank you very much in advanced.

Code:

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(newValue=='true'&& g_form.getValue('u_category')=='378ba2bbdbe697c0fc0792d8db9619a2'){
var id = g_form.getUniqueValue();
g_form.setMandatory('work_notes',true);

var att = new GlideRecord('sys_attachment');
att.addQuery('table_name','sc_request');
att.addQuery('table_sys_id',id);
att.query();
while (att.next()){

g_form.setValue('work_notes',g_form.getValue('work_notes')++'123');
}
}
if(newValue=='false'&& g_form.getValue('u_category')=='378ba2bbdbe697c0fc0792d8db9619a2'){
g_form.setMandatory('work_notes',false);
g_form.setValue('work_notes',' ');
//Type appropriate comment here, and begin script below

}

5 REPLIES 5

If possible please share the business rule as well, because i need to learn