- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 01:46 AM - edited 08-23-2023 01:56 AM
Hello Expert,
I tried using below script but no luck.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 02:34 AM - edited 08-23-2023 02:34 AM
On sys_attachment table fileName is field whose backend name is file_name
In your code ,you used fatt.file.toString() instead of att.file_name.toString(); and due to which your code is not working
Just use correct backend name of field Filename as given above .
By making above changes your code will give only the file name eg-text.pdf or text2.png
To get link of the attachment record use below code
var id;
<a href="https://<your_instance>.service-now.com/sys_attachment.do?sys_id=id&view=true" target="_blank">My Link</a>
Thanks,
Manjusha Bangale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 01:56 AM - edited 08-23-2023 02:00 AM
Hello @Shantanu K ,
Please try the below script in your query
filename = 'https://yourinstancename.service-now.com/nav_to.do?uri= .do?sys_id=' + att.sys_id.toString();
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 04:04 AM - edited 08-23-2023 04:04 AM
@Shantanu K If my answer helped you can mark my solution correct as well as servicenow allows multiple correct answers.
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 02:34 AM - edited 08-23-2023 02:34 AM
On sys_attachment table fileName is field whose backend name is file_name
In your code ,you used fatt.file.toString() instead of att.file_name.toString(); and due to which your code is not working
Just use correct backend name of field Filename as given above .
By making above changes your code will give only the file name eg-text.pdf or text2.png
To get link of the attachment record use below code
var id;
<a href="https://<your_instance>.service-now.com/sys_attachment.do?sys_id=id&view=true" target="_blank">My Link</a>
Thanks,
Manjusha Bangale