Recent

Nintex Forms conditionally require attachments

To only require attachments on forms some of the time, you will need to use a javascript function to evaluate the conditions to make attachments required.  If you want attachments required all the time, you can use the attachment control setting.

Conditional form file attachment(s)

In this example we are going to require at least 1 file attachment if the Request type is Conference or Training.

1.   Double-click on the control control you want to check the value of to make attachments required, in this case the Request Type field.
NF-Cond-Attachments-16-5

 

2. Expand the Validation section, select Yes for custom validation, type in ‘ValidateAttachments’, enter a descriptive message for attachments being required.
NF-Cond-Attachments-16-1

3. Next expand the Advanced section, select Yes for Client ID in Javascript, type in a Javascript variable name.
NF-Cond-Attachments-16-6

4. Click on the Nintex Forms tab, select Settings.  Expand the Custom Javascript section, paste in the following function:

function validateAttachments(source, arguments)
{
var elm = NWF$(‘.nf-attachmentsTable’);
var requesttypeValue = NWF$(‘#’ + RequestTypeClientID).val();
arguments.IsValid = true;if ((requesttypeValue == ‘Conference’) || (requesttypeValue == ‘Training’)) {
if (elm.length > 0 && elm.find(‘tr’).length >= 1) {
arguments.IsValid = true;
} else {
arguments.IsValid = false;
}}}

RequestTypeClientID refers to the Client ID you created in step 3.
The length >= 1 refers to the number of attachments required.

NF-Cond-Attachments-16-2

Finished Example: If someone selects either Conference or Training for Request Type, they will be required to include 1 or more attachments:NF-Cond-Attachments-16-4

About Nick Hurst (84 Articles)
SharePoint and Nintex developer who strives to find easy to deploy and maintain solutions for business problems.

1 Comment on Nintex Forms conditionally require attachments

  1. It is very useful article …..thanks nick

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: