Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Using Rules Editor to limit number of attachments

Avatar

Level 3

I recently noticed that you can either select one or multiple attachments for an adaptive form. I would l ike to limit the number of attachments to 4. How can I do that?

1 Accepted Solution

Avatar

Correct answer by
Employee

Simply use the following script in the validate event of the file attachment field. it works.

 

if(this.value.split("\n").length < 5)
  {
    true;
  }
else
  {false;}

 

Mayank_Tiwari_0-1633508804965.png

 

View solution in original post

3 Replies

Avatar

Employee Advisor

@lsmurph Can be handled but may require custom code. Let me see if I have one in the archive.

Avatar

Employee Advisor

@lsmurph use this on value commit of attachment: 

guideBridge.getFileAttachmentsInfo({
success:function(list) {
for(var i = 0; i< list.length; i++) {
// console.log(list[i].name + " "+ list[i].path);
if(list.length>4)
document.getElementsByClassName('button-default button-medium guide-fu-attach-button')[0].disabled=true;
}
}
});

Avatar

Correct answer by
Employee

Simply use the following script in the validate event of the file attachment field. it works.

 

if(this.value.split("\n").length < 5)
  {
    true;
  }
else
  {false;}

 

Mayank_Tiwari_0-1633508804965.png