Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Avoid duplicate attachments

Kim Kronborg
Kilo Expert

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);

}

 

7 REPLIES 7

Have you tried with page reload - did it work ?

Hi 

Yes Try it once.

How ?