cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
michellepm
Nintex Newbie

Validate Attachment using rules nintex forms 2010 & 2013

Jump to solution

Hi there

 

I have a attachment control which people must be forced to attach an item when leave day is more than 3 days and leave type = Sick leave and the control does not have any attachment

Below is the rule that I have used:

greaterThan(Calculatedfield,3) && LeaveType=="Sick Leave" && isNullOrEmpty({Self})

How ever the rule is not working..

 

Also

Force attachment when leave type = Study leave and Family Responsibility Leave

Rule = the control is inavild if LeaveType=="Study Leave/Family Responsibility Leave

On this one it validate the the attachment but even if you attached a document it does not allow you to save

 

Would appreciate any help regarding this.

Labels: (3)
Reply
4 Replies
Nintex Employee
Nintex Employee

Re: Validate Attachment using rules nintex forms 2010 & 2013

Jump to solution

Hi Michelle,

 

To achieve this purpose you need to use custom Java Script. Here is the sample

 

On Nintex Form Designer > Setting > Custom Java Script

 

function validateAttachments(source, arguments)

{

    var elm = NWF$('.nf-attachmentsTable');

    var calValue = NWF$('#' + calculatedDay).val();  

    var leavetypeValue = NWF$('#' + leavetype).val();  

   

    arguments.IsValid = true;

 

    if ((calValue > 3  && leavetypeValue == 'Sick Leave' )  || (leavetypeValue == 'Study Leave') || (leavetypeValue == 'Family Responsibility Leave'))  {

        if (elm.length > 0 && elm.find('tr').length >= 1) {

            arguments.IsValid = true;

        } else {

            arguments.IsValid = false;

        }

    }

}

 

Then you need to make sure that control calculatedDay and leaveType is configure with the same ClientID that we have defined in the function

In this case we have 2 control involved. CalculatedField and LeaveType

 

Open the control related.

Go to Advanced section.

Find field 'Store Client ID in JavaScript variable' choose 'Yes'

Fill up Client ID Java Script variable name  that specify in the java script above. In this case calculatedDay (attach to CalculatedDay) and leaveType (attach to control LeaveType)

 

The last thing is you need to make sure that this validation function are being called by one of the control in Nintex Form. In this case I use Leave Type to bind the validation

Go to control setting of Leave Type choice by double click the control. Open Validation section. On the Custom validation function field specify the value 'validateAttachments'.

 

Hope it works .

 

Thanks

Nita

View solution in original post

Reply
michellepm
Nintex Newbie

Re: Validate Attachment using rules nintex forms 2010 & 2013

Jump to solution

Hi there

Thank you, This case can be closed

Regards

0 Kudos
Reply
cmikhaiel
Nintex Newbie

Re: Validate Attachment using rules nintex forms 2010 & 2013

Jump to solution

Hi Elisabeth Yusnita, I'm trying to apply the same solution to my workflow. I need to make the attachments required when a checkbox is marked with no (not selected). I haven't written javascript before and was wondering if you can check this code.. does the name of the attachments table change from a form to another? or is this standard?!

NWF$('.nf-attachmentsTable')

function validateAttachments(source, arguments)
{
    var elm = NWF$('.nf-attachmentsTable');
    var mileValue = NWF$('#' + Mileageonly).val();  
    arguments.IsValid = true;
    if (milevalue == 'false' )  {
        if (elm.length > 0 && elm.find('tr').length >= 1) {
            arguments.IsValid = true;
        } else {
            arguments.IsValid = false;
        }
    }
}

Appreciate the help

0 Kudos
Reply
chaitra_b_c
Nintex Newbie

Re: Validate Attachment using rules nintex forms 2010 & 2013

Jump to solution

Hi Christine Mikhaiel class name of attachment control in Nintex form by default will be .nf-attachmentsTable and is standard.

Reply