cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

attachments custom validation

Jump to solution

I have need for very custom validation on an attachment field.

We have a series of cascading drop down menus that make the attachment field visible based on the selections. When the conditions that make the attachments visible I want to require an attachment. When the attachments are not visible, I don't want attachments to be required.

Anyone have a good way to go about setting this up? I don't see any way to do this with any of the out of the box functions and validation doesn't seem to work with rules either. I put a real simple condition like "IsEmptyOrNull" in the conditional validation field, and if I open the form initially then click save that validation kicks off, invalidates the form and puts my custom error message up, but the moment I select one of the cascading drop down options, the form "refreshes" and when I try to save the form, the attachment validation passes (even though I have not attached anything).

Reply
39 Replies
Workflow Hero

Re: attachments custom validation

Jump to solution
Reply
Workflow Hero

Re: attachments custom validation

Jump to solution

It does not cover conditional attachment validation only that it is required or not overall. Yes I have seen it.

Reply
Workflow Hero

Re: attachments custom validation

Jump to solution

I have written myself small javascript function that returns me number of attachemnets.


function GetNumberOfAttachments(attCtrlClassName){
   return NWF.FormFiller.Attachments.GetAttachedFilesCount(NWF.FormFiller.Functions.GetFillerDivObjectForControl(NWF$("#"+NWF$("." + attCtrlClassName + " .nf-attachmentsRow")[0].id)).data('controlid'))
}

then I simply use it in validation rules like

GetNumberOfAttachments("AttachmentControlClass") < 1

that allows me to combine it with other needed logic

attachments‌  custom validation‌ ‌ number of attachments‌

Reply
Workflow Hero

Re: attachments custom validation

Jump to solution

While this is nice, no where in my question did I ask for validation for the number of attachments. Where exactly are you going with this? I think this may be something you should put in a separate article or something as this is unrelated to my question.

Reply
Workflow Hero

Re: attachments custom validation

Jump to solution

you asked for:

When the conditions that make the attachments visible I want to require an attachment. When the attachments are not visible, I don't want attachments to be required.

number of attachments less than 1 means there is no attachment.

if you AND that with condition that makes your attachment control visible and place that combined condition into validation rule, once the control is visible and no attachment is included your form will not validate.

is it clear now?

Reply
Workflow Hero

Re: attachments custom validation

Jump to solution

Yes this makes more sense. I hadn't considered that method. Thanks for the clarification.

Reply
Workflow Hero

Re: attachments custom validation

Jump to solution

That's great, that's what I need!

Reply
Not applicable

Re: attachments custom validation

Jump to solution

Hi, ‌, do you have a solution via this thread? If so, can you click the "mark correct" button by the reply that got you there?  It's helpful for other community members who search for answers. Thanks!

0 Kudos
Reply
Workflow Hero

Re: attachments custom validation

Jump to solution

Unfortunately I was not able to get this solution to work for me. I was out until recently due to surgery and I haven't been able to explore further options yet.

Reply