Skip to main content
Nintex Community Menu Bar

Many times we have to validate attachment control inside a form on certain condition. For example, say, there is a checkbox on a form and when you check the checkbox you need to add an attachment (Mandatory) otherwise not. So how you will accomplish this? It's easy and here are the steps to follow:

 

  1. Create a custom function to check the named attachment is whether having a minimum attachment attached to it or not.
  2. Create a rule using that custom function where you have to pass the CSS class name of the attachment as a parameter to that custom function.

 

Follow the section below for detailed implementation:

 

The screen looks like as follows:

206850_pastedImage_1.png

 

Now if you check the AttachmentFlag, it’s mandatory to attach attachments. For that follow the following steps:

 

 

 

Step 1:

Goto NINTEX Forms -> Settings -> Custom Javascript and write the following function CountAttachments

function CountAttachments(cssClassNameOfTheAttachment){ 

    return NWF.FormFiller.Attachments.GetAttachedFilesCount(NWF.FormFiller.Functions.GetFillerDivObjectForControl(NWF$("#"+NWF$("." + cssClassNameOfTheAttachment + " .nf-attachmentsRow")a0].id)).data('controlid'));

 }

as follows:

206851_pastedImage_2.png

 

Step 2:

Select the attachment control and configure the CSS Class of it as follows:

206852_pastedImage_3.png

Step 3:

Configure the name of the ‘Yes/No’ field (AttachmentFlag) as follows:

206853_pastedImage_4.png

 

Step 4:

Now add a rule selecting the attachment control as follows:

206854_pastedImage_5.png

N.B. Remember you have to pass the CSS class name of the Attachment control as a parameter inside the function CountAttachments().

Now when you submit the form checking the AttachmentFlag and without attaching any attachment the following messages will be displayed:

206855_pastedImage_6.png

 

Hope this small blog will be helpful to you to validate any attachment control on demand. Thanks for viewing the blog!

Any idea how to repeat this for the Nintex Responsive form?


No, I haven't tried it out for Responsive form. I have doubt to put the above custom script inside NINTEX responsive form as it is not supporting it, if I am not wrong.


There is a method to imbed Java script in the responsive form.  Read up on this blog

Unable to find the Custom Javascript text area in Nintex Responsive forms

  for the post by Croos Nilukshan 28-Nov-2017 23:59.

Now I am  not sure how to get the css portion link up.  

Is it possible to do this same thing with a radio button choice instead of a yes/no selection?


Yes, it's possible. Inside the rule you need to check the choice field value.


That's where I'm hitting a wall...how do I check the choice field value?


Dear Sylvia,

You are using Nintex classic form. So don't worry about my post. My suggestion is for Nintex responsive forms.


Hey, can we do the same thing  for 4 check box?

I have four checkbox which are the name of the attachments.

1)Sap generated PR

2)Estimates

3)UBF

4)others

and for attachment control for each of these is below the checkbox field. The 1st checkbox is default and it is always nessecary, but I want to validate the remaining three fields when the user have checked but failed to provide any attachment.

I tried writing for one option :

NWF$(document).ready(function() {
NWF$('#' + Estimates ).change(function()
 var Attachments = NWF$("#" + Attachment).val();   //main control that has the 4 checkbox 
 var Estimates = NWF$("#" + Estimate).val();           //2nd option
 
 if((Attachments.val() == Estimates.val()) && (Estimates.val() = null){
  {
  

}


Thank you very much for this post, you've helped me a lot!!


Thanks!

Cheers!


Reply