Vadim Tabakman

If you haven't seen Nintex Forms, go and either download a trial or a hosted trial.  You'll find that if you have any number of fields in your list and generate a Nintex Form for it, it will automatically generate a visually appealing, user friendly form.  It's a very quick and easy way to have a nice form for user.

As part of a form for a List or even for a Task, a user can attach one or more documents.

What if you want a user to ALWAYS attach a document, and you don't want to allow a user to be able to complete the form without an attachment?

The easy way I found to do this, would be to create a custom validation function, link it to one of your fields (ie. the Title field).  If someone fills in the form and presses Save, the validation function will be called and if there's no attachment, validation will fail and the Save will not be allowed to proceed.

The following is the most simple Nintex Form, based on a list with just a Title field.

Form Design

To set a custom validation funtion, you simply double click on the Title text box and that will bring up the Control settings.  In the Validation section, you add a javascript function name.  That will be the function that is called when you leave the Title field or press the Save button.

Validation Function

Based on the configuration above, I need to create a javascript function called "validateAttachments".

In the form design, on the ribbon click on Settings.  Then expand the Custom Javascript section and that's where you put in the Javascript.

Custom Javascript

Here's the Javascript :

function validateAttachments(source, arguments)
{
 var elm = document.getElementById("idAttachmentsTable");
 var elmAttachmentRow = document.getElementById("idAttachmentsRow")
 if ((elm != null && elm.rows.length > 0) && (elmAttachmentRow != null))
 {
   arguments.IsValid = true;
 }
 else
 {
   arguments.IsValid = false;
 }
}

The Javascript simply checks the number of attachments in the current form.  If you add a custom validation error message, it will give the user and idea as to why validation failed.

Error Message

In the above example, I just put in a title value and presses Save.  You can see the message is telling us that either the data is invalid or you haven't added an attachment to this form.

Below, you can download this form and use it on a SharePoint Custom List with just a title field.  It's a very simply form and I didn't bother with sharing a List Template, since you can just go to create a Custom List and then import this form.

Downloads

Form Design: Download Form Design

Posted by Vadim Tabakman Tuesday, May 7, 2013 9:11:00 AM Categories: Attachments Nintex Forms
Copyright Vadim Tabakman
Rate this Content 0 Votes

Comments

Wednesday, October 2, 2013 3:19:51 PM
Remzi Kh

re: Nintex Forms - Attachment Required

Hi Vadim,

I need to build a custom validation for my initiation form.

Here is my scenario;

I have two People Picker and I dont want user to select same person for both fields.

I am pretty familiar with javascript but seems like i am not doing it right with nintex forms.

How I am going to get values for both picker and validate. Would you please throw me a sample code like above?

Much appreciated.

Thanks

Thursday, October 3, 2013 8:22:31 AM

re: Nintex Forms - Attachment Required

Hi Remzi,

I haven't had much luck with writing any JS that is flexible enough to read/update people picker fields.  I believe this functionality is being added to the product to make things easier, but I don't know exactly when it will be released.

cheers,

Vadim

Sunday, October 6, 2013 11:22:20 AM
Agung Suhendar

re: Nintex Forms - Attachment Required

help me

I create custom validation to overcome, if people picker is not filled but the red marks are not in place such as using people picker who rated the settings required in the beginning

Thursday, October 17, 2013 5:38:04 PM
cheedevi

re: Nintex Forms - Attachment Required

Is it possible to add conditional required validation to a text box control in repeating section? If yes can you please explain how to achieve this?

Tuesday, October 22, 2013 11:47:09 AM
Vadim Tabakman
Gravatar

re: Nintex Forms - Attachment Required

Hi cheedevi, I've never actually tried that. I don't have access to an environment at the moment. I'd suggest you email support@nintex.com. cheers, vadim
Tuesday, December 24, 2013 11:48:54 PM
Mariam

re: Nintex Forms - Attachment Required

Hi

I have built a function that checks the types of uploads, the only pre-requisit is to add a text-field with class "pdf-initializer" then hide it with code. Here's the complete code http://jsfiddle.net/Mfx_spointer/6PUXZ/1/ 

 

Thursday, December 26, 2013 10:31:28 AM

re: Nintex Forms - Attachment Required

Hi Mariam,

that's awesome.  Thanks for sharing that.

cheers,

Vadim

Monday, February 3, 2014 11:28:25 AM
Ellen Farley

re: Nintex Forms - Attachment Required

Hi Vadim,

I am attempting to use this example to help me with a custom validation.  

I have a form for a Delegation of Authority request.  I need to validate whether or not the user for whom the Delegation of Authority is being requested (the delegate) is a site controller.  If the delegate is not a site controller, then the form would be submitted to the site's controller, if the user is the site's controller the form would be submitted to the site controller's Manager.

I have a single line of text field on my form named EmpEmail, which is the delegate's email address.  I have a Yes/No field named Controller, which should be checked if the delegate is a site controller.  I want to validate that, if the delegate is one of 3 site controllers, the controller box is checked.  If not they should not be able to submit the form, until they check the box.

I have set use custom validation to Yes

Entered CheckControllerValue in the Custom Validation Function field and set the Custom error message to You must check the controller box to submit the form.

I don't really know Javascript, but I was able to put the following together from internet and Nintex forum queries. 

function CheckControllerValue(source,arguments)
{
var ControllerValue = (NWF$('#' + Controller).val();
var Designate =(NWF$('#' + EmpEmail).val();
if(Designate.toLowerCase().indexOf(toLowerCase('daniel.knox') > -1 && ControllerValue != Yes
|| Designate.toLowerCase().indexOf(toLowerCase('greg.paranto') > -1 && ControllerValue != Yes
|| Designate.toLowerCase().indexOf(toLowerCase('nancy.perham') > -1 && ControllerValue != Yes)
{
arguments.IsValid = true;
}
else
{
arguments.IsValid = false;
}
}

When I put this code in the Custom JavaScript field in form settings, the form ceases to load.  If I remove it, the form will load again.  As I said, I don't know JavaScript; so I think the issue is with my If Statement.   I would really appreciate any help you can offer.

Sunday, February 16, 2014 11:06:57 AM

re: Nintex Forms - Attachment Required

Hi Ellen,

I think you had some brackets missing and some in the wrong places.

I use a JavaScript Online Formatter like http://jsbeautifier.org and that can help a little, but you still need to find some things for yourself.

Try this:

function CheckControllerValue(source, arguments) {
  var ControllerValue = NWF$('#' + Controller).val();
  var Designate = NWF$('#' + EmpEmail).val();
  if (Designate.toLowerCase().indexOf(toLowerCase('daniel.knox')) > -1 && ControllerValue != Yes || Designate.toLowerCase().indexOf(toLowerCase('greg.paranto')) > -1 && ControllerValue != Yes || Designate.toLowerCase().indexOf(toLowerCase('nancy.perham')) > -1 && ControllerValue != Yes) {
    arguments.IsValid = true;
  } else {
    arguments.IsValid = false;
  }
}

cheers,

Vadim

Tuesday, April 8, 2014 9:37:59 AM
Carlos
Gravatar

re: Nintex Forms - Attachment Required

Good day Mr. Tabakman,

How did you add the attachment variable to the form in the first place?  Sorry but I do not see an attachment variable to attach documents (PDF, DOCX, XLSX) to a eForm.  Thank you.

 

Carlos

 

Tuesday, April 8, 2014 10:05:26 AM

re: Nintex Forms - Attachment Required

Hi Carlos,

there is an Attachment control in Nintex Forms.  You should just be able to add the control to your form.

Also, if you are building a form for a list, if it allows attachments, Nintex Forms will automatically put the control on the form.  If it's not allowed, it won't.

cheers,

Vadim

Thursday, April 10, 2014 9:57:01 AM
Carlos
Gravatar

re: Nintex Forms - Attachment Required

Hi Mr. Tabakman,

Thank you.  I could not find the control on the initial form that is submitted for the workflow, but I see the attachment control on the form for the flexi tasks.  This will work.  Thank you.

Carlos

 

Thursday, May 8, 2014 10:25:24 AM
Michal
Gravatar

re: Nintex Forms - Attachment Required

Hi Vadim

Tried this solution in every possible way, I get the validation prompt but when I attach a file and "Save" the validation still fails and I can't save the form.

Michal

Tuesday, June 17, 2014 12:53:46 AM
Jan
Gravatar

re: Nintex Forms - Attachment Required

Hello Vadim,

I have the same Problem that Michal described before! The interesting thing about it is, that this solutions works with Nintex Forms 2013  in Office 365 but not with Nintex Forms 2013 (latest version) On Premise (SharePoint 2013)!

Do you have any ideas?

Best regards,,

Jan

Monday, June 30, 2014 12:44:14 AM
Remus
Gravatar

re: Nintex Forms - Attachment Required

Hi Vadim,

This seem to work well for NF2010 1.4 and below. But for the newer version 1.5, this doesn't seem to work for attachment controls that are not specified as 'default'. Any update on how to do this for this new type of attachments? Thanks in advance.

Wednesday, July 2, 2014 4:26:33 AM
Greg Robinson
Gravatar

re: Nintex Forms - Attachment Required

Nintex Forms version 2.3 seems to have changed the html for the attachments control.  Previously, the ID of the control was 'idAttachmentsTable'.  Now the ID of the control is 'idAttachmentsTabled5ac7057-4d5e-41a0-9d51-3ee03b87154d'.  However, it looks like the GUID remains the same on this environment every time the form is opened.  

This is just another example of Nintex breaking things in newer Forms versions that worked in previous versions..

Wednesday, July 2, 2014 7:28:58 AM

re: Nintex Forms - Attachment Required

HI Greg,

it's not break things when you're improving.  Nintex has a great number of requests to have Nintex Forms support multiple attachment controls in the forms.

eg.  Having different parts of the form having their own attachments.

In order to do that, of course the internals of the form had to change to cater for this.  Price of progress :).

Hopefully, it's not too much of an inconvenience.  I'm currently trying to find a nice way with JS to cater for "required attachments" and at the same time, support multiple controls.

cheers,

Vadim

Tuesday, July 15, 2014 2:27:42 PM
SJNBham
Gravatar

re: Nintex Forms - Attachment Required

This seems to work for me with Nintex 2013 on-prem and Live:

function validateAttachments(source, arguments)
{
var elm = document.getElementById("idAttachmentsTable70b0d8cb-b654-4e56-adca-5be1326ce482");
var elmAttachmentRow = document.getElementById("idAttachmentsRow70b0d8cb-b654-4e56-adca-5be1326ce482")
if ((elm != null && elm.rows.length > 0) && (elmAttachmentRow != null))
{
   arguments.IsValid = true;
}
else
{
   arguments.IsValid = false;
}
}

Wednesday, July 16, 2014 2:07:31 AM
Kesava
Gravatar

re: Nintex Forms - Attachment Required

Why can't we use validation rule on the attachment to check for number of attachments and validate?

Tuesday, September 16, 2014 6:11:37 AM
Jibi
Gravatar

re: Nintex Forms - Attachment Required

Hi Vladmir,

 

Can we attach a custom nintex form to a sharepoint list through code ?? 

I need to create an app which will have a custom nintex form attached to sharepoint list??

Tuesday, September 16, 2014 8:54:20 AM

re: Nintex Forms - Attachment Required

Hi Jibi,

I would recommend you contact support@nintex.com or put a request on http://nintex.uservoice.com for this requirement.

cheers,

Vadim

Sunday, September 28, 2014 10:19:42 PM
Dan
Gravatar

re: Nintex Forms - Attachment Required

Hi Kesava,

This functionality is on the roadmap to be released soon. 

Monday, September 29, 2014 10:27:01 PM
Shruti
Gravatar

re: Nintex Forms - Attachment Required

Hi Team,

We are using Nintex Forms 1.5.4, do we have any workaround as the java script is not working for us.

Thanks,

Shruti

Tuesday, November 4, 2014 2:19:44 PM
Jennifer Helton
Gravatar

re: Nintex Forms - Attachment Required

We recently upgraded Forms 2010 and need to know how I can figure out the new GUID for the attachment table.  I had it working until the upgrade.  The ID provided below does not work in our environment.  Could you assist in telling me how you can locate this information?

Example from above discussion "The ID of the control was 'idAttachmentsTable'.  Now the ID of the control is 'idAttachmentsTabled5ac7057-4d5e-41a0-9d51-3ee03b87154d'."  

Tuesday, November 18, 2014 4:29:10 AM
SPFernando
Gravatar

re: Nintex Forms - Attachment Required

You have two options:

  1. Not getting by id, but start with (QuerySelectorAll).
    https://developer.mozilla.org/en-US/docs/Web/API/Document.querySelectorAll
  2. Using {ItemProperty:Attachments} property item, which returns true or false, and simplify arguments.IsValid.

Enjoy

 

Wednesday, April 22, 2015 1:54:46 PM
Ankita Rikhab Chand
Gravatar

re: Nintex Forms - Attachment Required

Hi,

Is there a way to disable the "Attachments control" based on a condition.

 Users should be able to read the attached files but not modify them.

 

Thanks,

Ankita

Thursday, April 23, 2015 9:39:31 AM

re: Nintex Forms - Attachment Required

You can build a Rule in NF to disable the Attachment control.

You won't be able to delete or add attachments, but if you right click on the attachments link, you'll be able to open the attachments in a new window/tab.

 

That's the only option I can think off.

cheers,

Vadim

Monday, June 8, 2015 12:02:20 AM
Ashish Kumar Singh
Gravatar

re: Nintex Forms - Attachment Required

Hi Vadim,

 

This is a nice post.

I need to know that is there a way to open the list attachments in a new tab or window.

Is there any settings or custom javascript can handle this.

Please help.

Wednesday, June 10, 2015 6:36:15 PM
Katherine
Gravatar

re: Nintex Forms - Attachment Required

Hi,

Can it be set so that the form only requires attachments if another field == "no"?

Thanks,

Katherine

Thursday, June 11, 2015 10:20:40 AM

re: Nintex Forms - Attachment Required

Ashish,

Nintex Workflows run on a server and as such, can not open anything on the client machine.

cheers,

Vadim

Thursday, June 11, 2015 10:24:56 AM

re: Nintex Forms - Attachment Required

Hi Katherine,

not at the moment, without some JavaScript.

cheers,

Vadim

Thursday, October 15, 2015 3:35:48 AM

re: Nintex Forms - Attachment Required

Hi Vadim,

I guess you understood Ashish's question wrong.

What he (and i) want to do is: If you click on an attachment, the file is opened in the same window and all entered into the form might be lost. Best would be if you click on the attachemnt and it opens automatic in a new browser tab.

I know this can be done, by right clicking the document, but i guess you can imagine, there is always someone that just clicks and then has to reenter all data again into the form.

 

br

michael

Thursday, October 15, 2015 9:51:15 AM

re: Nintex Forms - Attachment Required

Hi Michael,

oh I see.  I don't believe there is any setting in NF that will let you automatically open in a new windows.  I would recommend you put that on the http://nintex.uservoice.com site as a request.

Otherwise, I'd recommend you look at the source of the page and add some JS to your form that finds the attachment nodes and adds an attribute to them to open in a new window.  That should be do-able.

cheers,

vadim

Wednesday, October 28, 2015 5:31:27 AM
Chandra Shekhar
Gravatar

re: Nintex Forms - Attachment Required

Hi Vadim,

Thank you for the suggestions. I'm currently using Nintex 2013 and when I implement the code, the form can be saved even though the attachments are not there. Can you please check and confirm if that works for 2013 version?

Thursday, November 19, 2015 8:35:36 PM
Riya
Gravatar

re: Nintex Forms - Attachment Required

HI Vadim,

I tried your solution, but it is not working for Nintex form version (1.5.4.1)..is it another ways to make attachment mandatory with this version. as of now we are not planning to go for newer version. Tahnks

Friday, November 20, 2015 8:51:36 AM

re: Nintex Forms - Attachment Required

Hi Riya,

This post is a little old.  The attachment control now has validation on supported, so that you can say that at least one attachment is required.

https://community.nintex.com/community/tech-blog/blog/2014/11/14/attachment-validation-in-nintex-forms

Vadim

Tuesday, May 24, 2016 3:58:53 AM
Vish
Gravatar

re: Nintex Forms - Attachment Required

I wanted to change the error message text of a custom validation function. Is there any error message property of arguments such as arguments.ErrorMessage. Please let me know.

Tuesday, May 24, 2016 8:49:39 AM

re: Nintex Forms - Attachment Required

Are you talking about this post or the attachment validation that is now part of the Forms product?

Vadim

Tuesday, January 24, 2017 1:22:00 PM

re: Nintex Forms - Attachment Required

Hi Vadim,

I'm using Nintex 2010. and I can see now the validation for attachments to require a minimum number, but I need it only to be required on a condition when a checkbox is unselected. I've tried your form and it worked fine. but when used the EXACT same code on my form, it is not validating :-( I tried it on a single line of text rather than the checkbox.

Can you give a hint of what to look for that is preventing the form from validating? I've spent 2 full days on this with no progress...:'(

any help is appreciated!

Thanks!

 

Saturday, February 25, 2017 11:42:05 PM

re: Nintex Forms - Attachment Required

Hi Vadim,

I'm trying to make an attachment required by choice control value. All conditions are working properly and I see the console.log results: if it is the right value I see yes and if it is the wrong value I see no. Accordingly I have arguments.IsValid = true and arguments.IsValid = false. I have no error in console, and yet the attachment is not required and I don't have any validation error when I try to submit. The form is closing and the values are submitted.

Any idea how to debag it?

Thank you!

You must sign in to this site to post comments.
Already Registered?
Sign In
Not Yet Registered?
Register

Statistics

  • Entries (290)
  • Comments (1771)

Categories