Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Using Rules Editor to limit number of attachments

lsmurph
Level 3
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
Mayank_Tiwari
Correct answer by
Employee
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
Mayank_Gandhi
Community Advisor
Community Advisor

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

Mayank_Gandhi
Community Advisor
Community 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;
}
}
});

Mayank_Tiwari
Correct answer by
Employee
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