Download Attachment upon clicking an UI action in Workspace.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2022 12:05 AM
Hi All,
I have an UI action called Download Template in scoped application which downloads the attachment into system . I am trying to create a workspace View for the table and added the button in Form actions and added Workspace script . Upon clicking the Download Template button in workspace. It is redirecting to Picture 2 rather than downloading the attachment. IIt is working fine in UI 16 View Not working proper in Workspace. How to correct this . Please help.
Picture1:
Picture 2:
Thanks & Regards
Swathi Padighar
- Labels:
-
Workspace : Next Experience
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2022 03:11 AM
Hi,
action.setRedirectURL() won't work in workspace.
Can you share your existing UI action script
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2022 03:48 AM
This is the script which is present in UI action script .
var URL = '/sys_attachment.do?sys_id=' + attachmentSysID ;
action.setRedirectURL(url);
action.setReturnURL(current);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2022 05:01 AM
Hi,
As I already mentioned you need to write Workspace client script
Also the above script won't run in workspace
Also the script you shared is incomplete -> what does this attachmentSysID include?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2022 06:08 AM
Attachment Sys id is attachment' sysid which is stored in Servicenow and that is the complete UI action script. I am storing the attachment's sysid in a property and getting it .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2022 07:24 AM
Hi,
so you missed this part i.e. you are getting the attachment sysId from prpoperty
now what you can do is this
1) in workspace client script call GlideAjax and return the sysId from property
2) update the script as this
var attachmentSysID = ''; // this value will come from GlideAjax function
var URL = '/sys_attachment.do?sys_id=' + attachmentSysID ;
var win = top.window.open(url, '_blank');
win.focus();
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader