How to avoid file attachments with \special characters\" in file name?"


Badge +3

There are a number of "special characters" that SharePoint will not allow in file/folder names (e.g. &, #, %).  However, the browse function used by the Nintex "attachments" control allows users to select files with some of these characters in the file name.  This guarantees a failure which the user cannot understand or recover from. Sequence of events is something like:

  • User selects a file with "&" in the name to attach to a Nintex form.  No errors or warnings are generated.
  • User completes the form and clicks "submit".  The form exits and the associated workflow is invoked.  User is still unaware of any problems.
  • The workflow fails immediately when SharePoint tries to save the file name with the "&". A SharePoint error message is displayed ("Sorry, something went wrong...).
  • The user does not understand the error (even if the s/he understood the error, it is too late to get back to the form and address the file name issue).
  • All processing of this form fails and both the user and the intended recipient of the form (who never receives it) are unaware of the workflow failure.

I realize that the file name issue is with SharePoint, but I would think that Nintex forms could parse file names used as forms attachments.  If any characters are included in a file name which are know to fail in SharePoint, Nintex should inform the user immediately and instruct them to use a file name without the offending character(s).  This way the problem is corrected before the form is submitted and the workflow proceeds as intended.

Anyone else have this issue?  Any way to prevent users form attaching files with characters that SharePoint will reject?


33 replies

Badge +11

Hi Federico,

this Regex should work:

^(.)*(..)+(.)*$

Matches any string that has at least 2 "."

After checking for special characters you can check your attachments file name again to avoid having double "." inside

Badge +8

Thanks.

Fms.

Badge +9

What do you put under client click on the submit button?

Badge +11

For using this version you shouldnt need to put anything on the client click. The name gets validated whenever you try to add an attachment.

Cheers

Philipp

Badge +3

I just received a note from another user with probably a better solution.

But I do not put anything in the Client Click field. I just have a validation rule on the form (example below) and make sure that the Submit Button does validation. This way, I also get to display a more descriptive error message.

Thanks,

Ron Pillsbury

Business Systems Analyst

Goodwill Industries of Northwest NC

2701 University Parkway, Winston-Salem NC 27105

T| 336.724.3625 x1333 C| 336.749.8009

rpillsbury@goodwillnwnc.org<mailto:rpillsbury@goodwillnwnc.org>

Badge +9

Can you post detailed steps with screen shots on what you did to achieve this?

Badge +7

Thank you for this JavaScript function. It works great except I have one issue I'm not sure how to tackle now. I have some validation rules that don't seem to be firing at all now. If I remove the JavaScript function in the button's client click setting, then my validation rules behave as expected. I'm not sure how to get both the JavaScript and the validation rules to work in harmony.

Badge
This is a very nice solution with a minor bug. Based on my tests if you edit a form with an already uploaded attachment it will fail on file.find('span')[0].innerText, because the find('span') will be null.

It should be assigned to a variable and checked by an if.

Reply