0

JavaScript-TypeScript for Nintex Forms to Validate File Names

JavaScript-TypeScript for Nintex Forms to Validate File Names

 

This article is going to discuss how to implement JavaScript-TypeScript for Nintex Forms to Validate File Names before they’re uploaded to SharePoint.

 

When I was a complete newbie to SharePoint and developing Nintex forms that included file attachments, I had all sorts of fun learning about the extra special characters SharePoint doesn’t like in file names in addition to those already restricted by Microsoft Windows opreating system.

 

Yet I see a lot of Nintex form solutions which do not consider nor address those limitations.

 

Microsoft has published the whole list of not allowed characters here: http://support.microsoft.com/kb/905231

 

The Nintex Forms issue

The Nintex Forms “Attachments” control does not have an option to prevent file attachments with invalid file names with out of the box functionality.

 

Obviously, the only right way before storing the file in the SharePoint library using custom Nintex solutions is to validate attachment names before uploading.

 

JavaScript-TypeScript to the rescue!

To prevent users of SharePoint Nintex forms from attaching files with invalid characters, here is JavaScript-TypeScript for Nintex Forms to Validate File Names before uploading to SharePoint that you can use:

 

 

How to implement in your own Nintex Forms solution

In a nutshell:

  1. Create or Edit a custom JavaScript file for your Nintex form.
  2. Include the above JavaScript code.
  3. Open your Nintex Form in the form designer.
  4. Click the “Settings” button in the “Nintex Forms” tab’s main toolbar.
  5. Expand the “Advanced” section in the pop-up window that appears.
  6. Under “Custom JavaScript Includes”, put in the URL to reference your JavaScript file.
  7. Fine-tune and ‘tweak’ the script file for any references you may need to include, or the reference paths provided, for your particular server’s setup.

 

Viola!

 

Now whenever someone tries to attach a file to a Nintex form to upload into SharePoint:

  • they’ll receive a nice error message informing them their file with its current name isn’t allowed.
  • the attachment will be automatically removed from the Nintex Attachments control

 

So much more user friendly!

 

David Lozinski