I have a last name field and I want to add a validation that if it is empty AND the form has no attachments, then it is invalid. In other words either the last name needs to be filled or the form needs an attachment.....I can't get anything to validate against the attachment control. Any ideas?
have a look eg. here https://community.nintex.com/message/42744?commentID=42744#comment-42747
Thanks, I think this may work...=) Will try and let you know later.
Sorry I can 't get it to work. Not sure how to use it in junction with the isNullorEmpty. Also, which control would I use to invoke the function? If I add it to last name control, nothing validates on the form.
hard to say what are you doing wrong, you should post more details what exactly you are doing and what doesn't work.
check as well whether you aren't experiencing any errors in developer console
in general you should
- copy javascript code from link I provided into form settings/custom javascript
- create a validation rule with formula like this one and attach it to a control you want to get highlighted once validation fails
isNullOrEmpty(LastName) && GetNumberOfAttachments("AttachmentControlClass") < 1
- make sure you configured 'AttachmentControlClass' CSS class (without quotes) to attachment control.
I am trying to follow this and I am just not seeing the result like I would think I should. It's got to be something I am doing wrong... I am using
function GetNumberOfAttachments(attCtrlClassName){
return NWF.FormFiller.Attachments.GetAttachedFilesCount(NWF.FormFiller.Functions.GetFillerDivObjectForControl(NWF$("#"+NWF$("." + attCtrlClassName + " .nf-attachmentsRow")[0].id)).data('controlid'))
}
for my javascript and I have a choice field that I am trying to validate against when it results in "Fixed Assets"
I have set my attachment control CSS class to both attCtrlClassName and to AttachmentControlClass along with a validation rule of
Disposal Type == 'Fixed Assets' &&GetNumberOfAttachments("attCtrlClassName") < 1
anyways the form allows me to submit regardless of attachment... I am also attaching screenshots that may help show my error.. Thanks I know your busy and appreciate any feedback...
attachment control's CSS class you configure in setting dialog has to be input parameter to the GetNumberOfAttachments() function
so based on your screenshots, your formula should look like this
Disposal Type == 'Fixed Assets' && GetNumberOfAttachments("AttachmentControlClass") < 1
I've briefly looked on your xml and have found an instance of GetNumberOfAttachments with correct classname but with missing openning apostrophe, so this was likely your issue.
Thank You... That didn't seem to work so I must have something else wrong. I will try working on it a little more
I could not get it to work but ended up validating on the last name field instead with a custom validation:
function AttachmentNotNeeded(source, arguments)
{
var attachCount= GetNumberOfAttachments('nf-form-input-attachment');
var lastName=NWF$('#' + varLastName).val();
if(lastName=='' && attachCount<1)
{
arguments.IsValid=false;
}
else
{arguments.IsValid=true;}
}
function GetNumberOfAttachments(attCtrlClassName){
return NWF.FormFiller.Attachments.GetAttachedFilesCount(NWF.FormFiller.Functions.GetFillerDivObjectForControl(NWF$("#"+NWF$("." + attCtrlClassName + " .nf-attachmentsRow")[0].id)).data('controlid'))
}
Thanks for your help though. =)
Reply
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.