Change the "deleted attachment" message in "Ticket Attachments"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-23-2023 02:09 AM
Hi everyone Im trying to change the "deleted attachment" message in "Ticket Attachments", to show which attachment got deleted, but I dont know how to get the attachment, can anyone help with this ?
Code:
if (input && input.action == "deleted") {
gr.comments = input.action + " attachment";
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-23-2023 06:10 AM
@F_bio Santos sorry, I am not well versed with portal, I would leave other experts to probably have a look here.
I will try to explore at my end as well and would let you know if I have any findings.
Best regards
Suyog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-23-2023 06:26 AM - edited ā10-23-2023 06:26 AM
ok, ok @Suyog Aptikar thank you š
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-23-2023 06:27 AM
update as this to know the file name, see if this works for you
(function() {
data.sys_id = input.sys_id || options.record_id || $sp.getParameter("sys_id");
data.table = input.table || options.record_table || $sp.getParameter("table");
data.appendToId = options.appendToId;
data.table = _getActualTable(data.table, data.sys_id);
data.maxAttachmentSize = parseInt(gs.getProperty("com.glide.attachment.max_size", 1024));
if (isNaN(data.maxAttachmentSize))
data.maxAttachmentSize = 24;
data.largeAttachmentMsg = gs.getMessage("Attached files must be smaller than {0} - please try again", "" + data.maxAttachmentSize + "MB");
data.attachmentSuccessMsg = gs.getMessage("Attachment successfully uploaded");
data.noDragDropMsg = gs.getMessage("Attachment drap-and-drop not enabled - use attachment button");
data.noAttachmentsMsg = gs.getMessage("There are no attachments");
if (!data.table || !data.sys_id)
return;
var gr = new GlideRecord(data.table);
if (!gr.isValid())
return;
if (!gr.get(data.sys_id))
return;
if (input && input.action == "deleted") {
var att = new GlideRecord('sys_attachment');
att.addQuery('table_sys_id', data.sys_id);
att.query();
if(att.next()){
gs.addInfoMessage("Attachment " + att.file_name + " is deleted");
}
gr.comments = input.action + " an attachment";
gr.update();
}
data.canWrite = gr.canWrite();
data.canAttach = gs.hasRole(gs.getProperty("glide.attachment.role")) && GlideTableDescriptor.get(data.table).getED().getAttribute("no_attachment") != "true";
data.canRead = gr.canRead();
data.canDragAndDrop = gs.getProperty('glide.ui.attachment_drag_and_drop', 'true') === 'true';
function _getActualTable(table, id) {
if (!table)
return table;
var rec = new GlideRecord(table);
if (!rec.isValid())
return table;
if (rec.get(id) && rec.getValue('sys_class_name')) {
return rec.getValue('sys_class_name');
}
return table;
}
})();
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-23-2023 06:57 AM
Hi @Ankur Bawiskar for some reason it is only running the:
gr.comments = input.action + " the attachment: " ;
gr.update();
It is not running the :
if(att.next()){
gs.addInfoMessage("Attachment " + att.file_name + " is deleted");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-23-2023 07:17 AM - edited ā10-23-2023 07:24 AM
@F_bio Santos can you replace gr.comments = input.action + " an attachment"; with
gr.comments ="Attachment " + att.file_name + " is deleted";
and see if this helps
something as below:
if (input && input.action == "deleted") {
var att = new GlideRecord('sys_attachment');
att.addQuery('table_sys_id', data.sys_id);
att.query();
if(att.next()){
gs.addInfoMessage("Attachment " + att.file_name + " is deleted");
gr.comments = "Attachment " + att.file_name + " is deleted";
}
gr.update();
}
Best regards
Suyog