Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

How to tell if there is anything attached to the form


Level 3

I need a script to let me know if any other documents/pictures/etc. are attached to the form.

I have a user who wants a message to appear "This form has items attached!" if anyone attaches documents to it. This way if they happen to not have the attachment window open, there is a visual telling them to check it.

I tried to do it simply, but it doesn't seem to be working at all. I created a blank text input field, and put the following on the calculate event:

var myDoc = event.target;

var d = myDoc.dataObjects; //get the attachments

if (d.length >= 0) { //if the length of the attachments is greater than or equal to zero then

        this.rawValue = "This document has attachments!"; //display message in text input field


This doesn't display anything at all in my field. I'm drawing a blank and I can't seem to find much reference on the properties of attachments.

0 Replies