Avoid duplicate attachments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2018 01:13 PM
I have this before BR on sys_attachment table where I want to filter out duplicate attachments for the incident table. So if the user tries to add a file that's already present on the incident then it's not possible.
It seems to work on London release but not on Kingston - the manage attachments prompt just hangs when I activate the BR on Kingston.
Any suggestions to why it doesn't work on Kingston ?
Condition : current.table == 'incident'
Script:
var sysId = current.getValue('table_sys_id');
var fileName = current.getValue('file_name');
var foundDuplicate = false;
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id', sysId);
gr.query();
while (gr.next()){
if (gr.getValue('file_name') === fileName){
gs.log('Duplicate filename found in incident, action should be aborted');
foundDuplicate = true;
}
}
if (foundDuplicate){
current.setAbortAction(true);
}
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2018 11:48 PM
Have you tried with page reload - did it work ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2018 11:50 PM
Hi
Yes Try it once.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2018 11:52 PM
How ?