cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

Cannot get Attachment Validation to Work

I've been following this article on how to conditionally require an attachment on a Nintex form and I haven't had any luck getting it to work.  I suspect, because I'm no expert on JavaScript, I've somehow modified the code incorrectly.

What I am trying to do is that if the Status field is set to "Completed" then there must be a minimum of two attachments. I should also explain that the Status field is a drop-down containing a selection of "Completed" along with "Not Started" and "In Process".

Thanks for your assistance.

  1. function validateAttachments(source, arguments)
  2. {
  3. var elm = NWF$(‘.nf-attachmentsTable’);
  4. var statusValue = NWF$(‘#’ + StatusClientID).val();
  5. arguments.IsValid = true;if (statusValue == ‘Completed’) {
  6. if (elm.length > 0 && elm.find(‘tr’).length >= 2) {
  7. arguments.IsValid = true;
  8. } else {
  9. arguments.IsValid = false;
  10. }}}

Status field config

Tags (1)
0 Kudos
Reply
7 Replies
Workflow Hero
Workflow Hero

Re: Cannot get Attachment Validation to Work

Thank you; however, I cannot seem to get this to work.  Also, I've test this below and created a variable and then referenced this variable within a calculated field I've placed on the form to see what it would render during runtime and it's not returning anything:

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

Here's how I implemented it just in case I've missed something:

Form Setting JavaScript

Attachment CSS class

Status Field Validation Rule Formula

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Cannot get Attachment Validation to Work

Check usage of GetNumberOfAttachments function carefully.

you have supplied wrong selector as its input parameter, it should have been "attCtrlClassName" which you have configured as 'CSS Class' for attachment control, instead of 'nf-form-input'

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Cannot get Attachment Validation to Work

I've made the correction and it still does not work:

Status=="Completed" && (GetNumberOfAttachments("attCtrlClassName") <1)

I've also attached the actual form.

Thanks again for the help.

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Cannot get Attachment Validation to Work

it looks like you are on forms 2010, I've tested the script on 2013...

can you check developer console whether you do not get reported any errors there?

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Cannot get Attachment Validation to Work

Developer's console?  You mean within the web browser?

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Cannot get Attachment Validation to Work

yes, in browser. - press F12, run the form and check console for errors.

0 Kudos
Accept as Solution Reply