daniel.kinal@nintex.com

Attachment Validation in Nintex Forms

Blog Post created by daniel.kinal@nintex.com on Nov 14, 2014

Validation is a crucial piece of functionality for almost any form. As a designer of a form I want to ensure that only data that meet certain criteria can be entered and, as I define my columns, SharePoint gives me some of that functionality out of the box. So… that’s great, right?

 

Almost. There is one critical area of data input where there is almost no straightforward way to validate that the right kind of data is being submitted: SharePoint’s attachment functionality. Aside from a central set of disallowed attachment file formats and some limitations on attachment sizes, a user really can add as many (including zero) of whatever attachment type he or she likes.

 

For a collaboration environment, attachments to data input are crucial and the designer of a workflow needs to have the means to ensure only the right attachments are submitted. This is also an issue of usability for the person entering the data who needs to feel confident that they have done the right thing. We know that many of our customers have often looked to plug this gap, and some have had some measure of success using custom JavaScript.

 

Unfortunately, custom JavaScript can be tricky to get right and difficult to maintain so we’re now addressing this issue in the core product.


An example where attachment validation is important might be a Job Application Form. Typically, a job application requires a résumé to be attached. Sounds simple. But behind this simple request are actually a couple of implications that are critical in ensuring that anyone downstream in the workflow from this submission is getting the right information:

  1. Only one résumé should be attached to any single job application. More than one attachment and the person reviewing the submission is getting more information than they asked for. If there is no résumé attached, then the application is worthless.
  2. Only certain file formats are valid as résumés (e.g. Word documents, PDFs). Other file types may not be suitable for keyword scanning and may not even be viewable by the recruiter or hiring manager.

 

The latest version of Nintex Forms for SharePoint includes validation for attachments baked in to the Attachment Control. A new “Validation” section in the Attachment Control settings is now available. You’ll see that it allows the designer of the form to:

  • Specify a minimum number of attachment files for the control,
  • Limit the attachment control to a maximum number of files, and
  • Define a “whitelist” of acceptable file extensions.

Validation Section.png


You’ll also see that you can define validation messages where the minimum number of files have not been submitted and where an incorrect file format is being submitted.


So how does this work in practice?


Minimum Attachments

This one is pretty clear-cut. If the user tries to submit a form without the minimum number of attachments specified, then the form will not be submitted and the user is presented with a validation message. In the example above, I have specified that at least one attachment is required and I’ve set a custom validation message of “Résumé must be attached.”


Also, where the minimum number of files is greater than zero, we treat the control as a required field and the connected label is marked with a red asterisk to denote the attachment control as “required”.


Maximum Attachments

This one is even easier. The designer of the form can leave the Maximum Attachment Setting to “Unlimited” which is the default. In the example above, however, I’ve said that I don’t want a user to submit any more than one attachment. So, what happens if they try?


At runtime, once the number of attachments has reached the maximum number specified, the “Add Attachment” button on the form becomes disabled and is grayed-out so that no more files can be attached.


This also means that a validation message is not required for the user. However, we would recommend that, where there is ambiguity, the form designer make it clear in the form that there is a maximum number of attachments allowed.


Allowed File Formats

If left blank, any file format is allowed. However, as soon as any extensions are entered into this list, then this acts as a whitelist. Nintex Forms will not allow any files with an unlisted file extension to be uploaded. In the example above, I’ve stated that only files with the extension doc, docx or pdf will be allowed.


The way validation works here is a bit different. It’s not that Nintex Forms stops the submission of the form, it actually prevents the attachment at upload time – before the user even submits the form. When the user attempts to upload a disallowed file type, then a dialog box appears with my custom validation message. The file is not even uploaded.

 

Attachment Dialog.png

 

So that’s it: our new attachment validation in action.


We really hope you like it and we’re looking forward to making validation for attachments even more flexible. In the not too distant future we hope to deliver the ability to set Validation Rules for attachments as well, offering the same sort of conditional validation to attachments as we do to our other controls. We are also, of course, planning to include this functionality in Nintex Forms for Office 365 as well. Stay tuned.

Outcomes