Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Stopping attachment action

Avatar

Level 2

Hi

Is the a way i can stop a user from attaching a document if the file name already exist within the files that are already attached.Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 8

You could loop through the names and remove duplicate attachments when the user submits or saves

app.execMenuItem("AddFileAttachment");

var d = event.target.dataObjects;

for (var i = 0; i < d.length; i++)

{

    TextField.rawValue =  d[i].name;

}

View solution in original post

3 Replies

Avatar

Correct answer by
Level 8

You could loop through the names and remove duplicate attachments when the user submits or saves

app.execMenuItem("AddFileAttachment");

var d = event.target.dataObjects;

for (var i = 0; i < d.length; i++)

{

    TextField.rawValue =  d[i].name;

}

Avatar

Level 2

Hi,

The thing is i want to stop it and displays a message saying it already exist.

I was thinking this should work "event.cancelAction()"

Avatar

Level 2

And  this wil not work in the cases when user add/remove attachments from the attachments panel.

So i was looking for an event which fires immediately when a user attaches/removes file from the attachment panel, so that the text field refreshes automatically.