Rename file attached to the notification when user downloads the file from the email notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi! How can I achieve renaming a file attached to the notification once downloaded? I want to achieve something like ---> user downloads attached file from the notification ----> the requester's name will be added in the beginning of the file. It is displayed correctly in the email body, but after downloading, it displays the original file name. Any idea?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
if user receives email with the attachment then they are doing the action in their outlook or email application which is outside ServiceNow application.
how would ServiceNow be able to handle this -> No this is not possible.
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hope you are doing good.
Did my reply answer your question?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @oww15
the email client (like Outlook) will always show the file name that was sent in the email's headers, not the display name in the email body,
Give a try to Before Insert Business Rule on sys_email
(function executeRule(current, previous /*null when async*/) {
var grSource = new GlideRecord(current.target_table);
if (!grSource.get(current.instance)) {
gs.warn('Email attachment renamer: Could not find source record ' + current.instance);
return;
}
var requesterName = grSource.getDisplayValue('requested_for');
if (gs.nil(requesterName)) {
requesterName = 'User';
}
// Find all attachments that have been copied to THIS email record
var grAttach = new GlideRecord('sys_attachment');
grAttach.addQuery('table_name', 'sys_email');
grAttach.addQuery('table_sys_id', current.getUniqueValue());
grAttach.query();
// Loop through each attachment and rename it
while (grAttach.next()) {
var originalName = grAttach.getValue('file_name');
// This is your new file name format
var newName = requesterName + '_' + originalName;
grAttach.setValue('file_name', newName);
grAttach.update();
}
})(current, previous);
Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning
Thanks & Regards
Deepak Sharma
