Skip to main content
Nintex Community Menu Bar

How can I make attachments required if a particular box is checked?

  • Oct 24, 2017 5:07 PM UTC
  • 18 replies
  • 228 views
  • Translate All

Forum|alt.badge.img+6

I have very little JS knowledge.  I can follow some, but am lost with most.  So I've read a similar question, only rather than a checkbox, the example shows attachments being required based on the value in a dropdown list.

If the "Are there existing Map(s)?" box is checked, I need at least one attachment to be required.  Please help! Thanks!

210001_pastedImage_1.png

18 replies

Forum|alt.badge.img+6
  • Oct 25, 2017 6:16 AM UTC

Hi,

Have you seen this post?

number of attachments based on calculated field value  

I would add the GetNumberOfAttachments function to the forms Custom Javascript section, change the CSS Class as shown on the Attachments control and then add a validation rule that checks if the "Existing Maps" checkbox is checked or not in combination with the outcome of the GetNumberOfAttachments function, alerting as appropriate.

Cheers,

Mark

Translate

Forum|alt.badge.img+6
  • Author
  • Novice
  • Oct 25, 2017 11:48 AM UTC

I saw that post, however, I am still completely lost with how to factor in my titles and the checkbox. My JS knowledge is very minimal.

Translate

Forum|alt.badge.img+14
  • Scholar
  • Oct 25, 2017 1:16 PM UTC

for yes/no checkbox validation formula should simply be

cbMapsExists && GetNumberOfAttachments("AttachmentControlClass") < 1‍

cbMapsExists is Named Control reference for the checkbox

210044_pastedImage_2.png

AttachmentControlClass is CSS class assigned to attachment control

210045_pastedImage_3.png

Translate

Forum|alt.badge.img+6
  • Author
  • Novice
  • Oct 25, 2017 2:33 PM UTC

Thank you for the reply!

I set the CSS name on the Attachments as AttachmentControlClass.  And I have the checkbox name as "ArethereexistinsMaps."  Below is the validation formula I added to the Yes/No checkbox.

When I check the box and submit the form with no attachments, I do not get an error.  I am still able to submit without attachments.

Anything I am missing?

210031_pastedImage_1.png

Translate

Forum|alt.badge.img+14
  • Scholar
  • Oct 25, 2017 3:23 PM UTC

as mentioned above, you have to add checkbox to the formula as Named Control reference, not just simple type it in

it has to get red in formula builder.

210047_pastedImage_2.png

Translate

Forum|alt.badge.img+6
  • Author
  • Novice
  • Oct 25, 2017 3:38 PM UTC

I do not see a Named Controls tab...

Am I inputing this formula in the wrong area?  I have put this under the validation on the yes/no checkbox...

210051_pastedImage_1.png

Translate

Forum|alt.badge.img+14
  • Scholar
  • Oct 25, 2017 3:47 PM UTC

you have to create validation rule assigned to (the best) attachment control

210054_pastedImage_1.png

Translate

Forum|alt.badge.img+6
  • Author
  • Novice
  • Oct 25, 2017 4:02 PM UTC

Thank you for your continued help and patience...

I think I have it set now.  However, it's still allowing me to submit the form without an attachment.  No error message.  Anything else I need to do?  Does it not automatically activate?

210057_pastedImage_1.png

210058_pastedImage_2.png

Translate

Forum|alt.badge.img+14
  • Scholar
  • Oct 25, 2017 9:17 PM UTC

- can you post configuration of "ArethereexistinsMaps" control

- can you post configuration of attachment control?

- have you added script for GetNumberOfAttacments() function into from settins >> Custom javascript?

- open developer console (F12) and run/reload the from. check the developer console whether there are not reported any errors

Translate

Forum|alt.badge.img+6
  • Author
  • Novice
  • Oct 30, 2017 1:50 PM UTC

ArethereexistingMaps config:

210154_pastedImage_1.png

Attachments config:

210155_pastedImage_2.png

I added this Custom JS:

210156_pastedImage_3.png

F!2: No reported errors

Translate

Forum|alt.badge.img+14
  • Scholar
  • Oct 30, 2017 2:21 PM UTC

- remove validation function content from ArethereexistinsMaps' control settings and set its 'use custom validation' to no

- you likely do not call validateAttachements() function anymore, so remove this function from custom javascript.

- copy&paste function GetNumberOfAttacments() from following link into custom javascript

https://community.nintex.com/message/42747?commentID=42747#comment-42747 

Translate

Forum|alt.badge.img+6
  • Author
  • Novice
  • Oct 30, 2017 2:36 PM UTC

Thank you for your continued help!

I've pasted that formula in my JS. Though, I'm sure I did it wrong (as it's still not working). 

Below is a screenshot of the JS and the Validation rule:

210161_pastedImage_1.png

Translate

Forum|alt.badge.img+14
  • Scholar
  • Oct 30, 2017 2:42 PM UTC

with removing validateAttachements() function from custom javascript I meant to remeve it including its body, not just its name.

do it once again: clear whole custom javascript content and paste there just GetNumberOfAttacments() function from the link provided.

Translate

Forum|alt.badge.img+6
  • Author
  • Novice
  • Oct 30, 2017 2:46 PM UTC

Still not working:

210162_pastedImage_1.png

Translate

Forum|alt.badge.img+14
  • Scholar
  • Oct 30, 2017 8:09 PM UTC

can you post screenshot of attachments control configuration dialog with formatting section expanded?

Translate

Forum|alt.badge.img+6
  • Author
  • Novice
  • Oct 31, 2017 12:57 PM UTC

210224_pastedImage_1.png

Translate

Forum|alt.badge.img+14
  • Scholar
  • Oct 31, 2017 1:10 PM UTC

where did you come to this syntax of CSS class definition???

put there simply:

nf-form-input AttachmentControlClass

validate‌ attachment‌   ‌ ‌ ‌ ‌

Translate

Forum|alt.badge.img+6
  • Author
  • Novice
  • Oct 31, 2017 2:02 PM UTC

Yes!!!  It works!  Thank you for all of your help!

Translate