Can you validate the minimum attachments as a condition?


Badge +2

I have a form in which some questions and attachments are hidden unless a certain option is selected.

E.g. Question 1 - Option 1 / 2

If option 2, further questions and attachment fields appear.

I need all attachments to be mandatory; I have tried setting the minimum attachments field in the Control Settings to 1, but this would prevent the form from saving if Option 1 was selected.

Is there a way to set the minimum attachments as a condition?

I.e. - If Question 1 = Option 2, min = 1, else min = 0.

Any help would be appreciated. Thanks.  


10 replies

Userlevel 5
Badge +14

see my following post https://community.nintex.com/message/42747?commentID=42747#comment-42747 

Badge +2

Hi,

function GetNumberOfAttachments(attCtrlClassName){  
return NWF.FormFiller.Attachments.GetAttachedFilesCount(NWF.FormFiller.Functions.GetFillerDivObjectForControl(NWF$("#"+NWF$("." + attCtrlClassName + " .nf-attachmentsRow")[0].id)).data('controlid')) 
} 
‍‍‍‍‍‍‍‍‍‍‍

I'm new to JavaScript so could you please explain this, including where to put this code (I assume Form Settings > Custom Javascript).

Thanks.

Userlevel 5
Badge +14

yes place the code into custom javascript.

configure for attachment control you want to check  'attCtrlClassName' CSS class (without quotes)

set up a validation rule with formula: Question1 = "Option 2" && GetNumberOfAttachments("attCtrlClassName") < 1

Badge +2

configure for attachment control you want to check  'attCtrlClassName' CSS class (without quotes)

I still don't understand this step. I don't see how a CSS class could do anything. Could you please provide screenshots?

Userlevel 5
Badge +14

Badge +2

I have done this and it's still not working. Am I doing something wrong?

193072_pastedImage_3.png

193074_pastedImage_5.png

193075_pastedImage_6.png

193077_pastedImage_8.png

Userlevel 5
Badge +14

if I count braces in your formula correctly you miss there one closing brace that would close and() ...

Badge +2

Thank you! It works now.

Only problem is that now that the CSS class has changed, I've lost my blue background on the attachment control; is there a way to access the attCtrlClassName CSS code to modify it? The CSS I was using before was nf-form-input nf-section.

Also, if could you please explain the separate parts of the javascript code it would really help. Thanks.

Userlevel 5
Badge +14

hurray!  happy.png

Only problem is that now that the CSS class has changed

this is not a  problem, you can define as many CSS classes as you need.

so, add all the needed classes separated by space, like "nf-form-input nf-section attCtrlClassName"

is there a way to access the attCtrlClassName CSS code to modify it

the class has no definition (OOTB). it's just used as a identifier for the control.

if you want/need you can define whatever styling to the class you need

if could you please explain the separate parts of the javascript code

there is not too much to explain, I just used two built in NINTEX's functions which identified attachment control by its classname and returns its number of files .

Badge +2

Thank you

Reply