Form Attachment Validation with JavaScript

  • 21 December 2021
  • 0 replies
  • 122 views

Badge +7

I was previously using a custom validation function on a form to check for attachments, and more specifically, if 'a certain string' appeared in the filename:

 

NWF$("tr[id^='attachRow']").each(function() { var arrParts = NWF$(this).find(".ms-addnew")[0].href.split('"'); var fileName = arrParts[5]; var match = (new RegExp('a certain string', 'i')).test(fileName); if (match) matchFound = true; });

 

This was working in Nintex version 4.3.3.0. However, since updating to version 4.6.1.30 this ceased to work. It appears as though attachments started to appear in the DOM differently now. So, I had to modify the code as follows:

 

NWF$("tr[id^='attachRow']").each(function() { var fileName = NWF$(this).find(".ms-vb")[0].innerText; var match = (new RegExp('a certain string', 'i')).test(fileName); if (match) matchFound = true; });

 

I'm aware that relying on JavaScript is susceptible to these types of changes, as noted in the Release Notes:

 

Important: Forms releases may include changes of some controls. If you are using custom JavaScript, it may require adjustments to your custom JavaScript.

 

But is there a way to be a bit more prepared for upcoming changes? Or is it always a case of just installing (on a dev server, of course), test everything and seeing what breaks?

 

 

 

 


0 replies

Be the first to reply!

Reply