Validation on multiple attachment control

  • 26 April 2017
  • 3 replies
  • 11 views

Badge +2

Hi experts, happy.png i'm a beginner in Nintex and need help here..

I wanted to have 2 attachment controls with following validation respectively, somehow I'm unable to get the correct result. Not sure if anyone can help me out on this..

Expected result:

Validation check should be according to the individual attachment control. When Equipment type = FOAK,

both attachment must attach at least 1 document respectively.

e.g:

1st attachment control = 1, 2nd attachment control = 1 --> PASS

1st attachment control = 0, 2nd attachment control = 0 --> FAIL

1st attachment control = 1, 2nd attachment control = 0 --> FAIL

1st attachment control = 0, 2nd attachment control = 1 --> FAIL

Actual result:

1st attachment running fine. 2nd attachment is NOT. Validation pass as long as there is an attachment in the form.

e.g.

1st attachment control = 1, 2nd attachment control = 1 --> PASS

1st attachment control = 0, 2nd attachment control = 0 --> FAIL

1st attachment control = 1, 2nd attachment control = 0 --> PASS

1st attachment control = 0, 2nd attachment control = 1 --> FAIL

Following are how i configured in the control setting + javascript

1) 1st attachment control (Attachment2)

     - minimum attachment = 1

     - control setting:

2) 2nd attachment control (Attachment_1)

    - minimum attachment = 1 if "Equipment Type" = FOAK

    - control setting for attachment:

   - control setting for Equipment Type:

hence, i use JavaScript as below for 2nd attachment control as it can only be done using javascript.

function validateAttachments(source, arguments){
 var attCount=NWF$('.nf-attachmentsTable').find('tr').length;
 var statusVal = NWF$('#' + EQType).val();  //NWF$('val-status select').val();

 if(statusVal.lastIndexOf("FOAK") >=0 && attCount <1){
    arguments.IsValid = false;
    if (NWF$('.nf-validation-summary').css('display') != 'none'){
         NWF$('.nf-attachment-control').css("border", "red solid 2px");
   }
  }

else {
    arguments.IsValid = true;
    {
     NWF$('.nf-attachment-control').css("border", "none");
     }
  }
 
}

Thank you so much..~laugh.png


3 replies

Userlevel 5
Badge +13

Can you not use a validation rule? Have the rule configured such that the Attachment 2 control is invalid if isNullOrEmpty{Self} && Equipment Type == "FOAK" ?

Badge +2

I removed the validation rule but it still does not work.

I have tried isNullOrEmpty{Self} && Equipment Type == "FOAK", unfortunately, it does not work that way. sad.png 

I created 2 attachments where label name are Attachment2 and Attachment_1 respectively. But, in "Name Controls" and "Items Properties" I cannot find any of the fields mentioned, only "Attachment" shown in Item Properties where it only carry the value true or false. I believe it is an default attachment field for all.

The only way I found is to use JavaScript for attachment validation. Somehow, it does not solve my issue 100%. Not sure if you have any better idea for this.. happy.png 

Userlevel 5
Badge +14

have a look on these examples https://community.nintex.com/search.jspa?q=GetNumberOfAttachments 

if you configure different class to every attachment control, you should be able to validate them independently.

Reply