Get sys_id of attachment in ui action

Rosy14
Tera Guru

Hi, I have a button on workbench.. I want to download the attachment of the record. it is not working. Button is on workspce.

Rosy14_0-1709804695773.png

function onClick(g_form) {

    var sysID = g_form.getUniqueValue();
    var gr = new GlideRecord("sys_attachment");
    gr.addQuery('table_sys_id', sysID);
    gr.query();
    while (gr.next()) {
        var attSysID = gr.sys_id;
    }
	alert(sysID);
    var URL = '/sys_attachment.do?sys_id='+attSysID;
    //window.open(URL, '_blank');
    //action.setRedirectURL(URL);
    //action.setReturnURL(current);
    top.window.open(URL, 'blank');
}
10 REPLIES 10

there is only one attachment.. I want to download it by button only