How to elimiate duplicate attachment in inbound actions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2018 11:27 PM
Hi i have an req using inbound actions
I sent mail with attachments ( A and B) on other day i sent one more mail with attachments (A and B)
incident was created but attachments should not load it give the previously loaded attachment data
is it possible if yes can you tell me the way
or
any business rule we should create ???????
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2018 11:43 PM
Hi,
Write a before BR on attachment table for insert and update.
This will not allow to add duplicate attachment for a record.
Script:
function onBefore(current, previous) {
var attach = new GlideRecord('sys_attachment');
attach.addQuery('table_sys_id', current.table_sys_id);
attach.addQuery('table_name', current.table_name);
attach.addQuery('file_name', current.file_name);
attach.addQuery('content_type', current.content_type);
attach.addQuery('size_bytes', current.size_bytes);
attach.query();
if(attach.next()){
current.setAbortAction(true);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2018 12:05 AM
That script is doesn't working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2018 12:42 AM
HI Vishal Thanks for reply
the given script is working for while we are attach the attachments in incident form
but my question
if i attached with file name as A and created the incident on same other day same file name i attach
at that time i show and error this file is exist on particular incident table like that
is it possible
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2018 02:09 AM
write a before insert business rule on sys_attachment table
var attachRec = new GlideRecord("sys_attachment");
attachRec.addQuery("table_name", current.getTableName());
//attachRec.addQuery("table_sys_id", current.sys_id);
attachRec.query();
if (attachRec.next()) {
gs.addErrorMessage("You must attach a complete import template before submitting.");
current.setAbortAction(true);
}
hope it will help you.
thank you