Download Attachment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2017 10:01 AM
Hi,
I am trying to download a attachment from business rule. Because, I want to download attachment when it is created on "sys_attachment" table. Is it possible?
The only way I found to download attachment is by using action.setRedirectURL('sys_attachment.do?sys_id=' +SOME SYSID) in UI Action. Is there any other way to do this?
Note: I tried gs.setRedirect() in business rule. But no use.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2017 10:02 AM
You cannot download an Attachment from a Business Rule.
Can you explain the business problem you are trying to solve?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2017 10:11 AM
We have a UI Action which creates a PDF and attached to the table as attachment. The users also want the attachment to be download at the same time. Is there any way to call UI Action from any script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2017 10:29 AM
After the UI Action attaches the attachment to the record, use gs.setRedirect() with the URL to the attachment that was attached before. If it is still unclear, please post the UI Action.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2017 10:39 AM
var attach = new GlideRecord('sys_attachment');
attach.addQuery('table_sys_id', current.sys_id);
attach.addQuery('table_name', 'u_req');
attach.orderByDesc('sys_created_on');
attach.query();
if(attach.next()){
gs.setRedirect('sys_attachment.do?sys_id='+attach.sys_id);
gs.log('Attach: '+attach.file_name);
}
This will download the attachment which is created early but not the latest one. As latest one is created after running the UI Action.