Need to Verify Multiple Attachments Controls are not Null


Badge +7

I have 3 attachment controls with one set to default. They each have unique name and a CSS class "attCtrl."

I need to be able to verify that each has been uploaded, or not null. If one is null I need to know which one. 

I thought I could use the name of the control to determine if it was "not empty," but I have not been able to do that.

Does anyone have any advice for this?


13 replies

Userlevel 5
Badge +14

have a look on this my little function https://community.nintex.com/message/42747?commentID=42747#comment-42747 

but,

They each have unique name and a CSS class "attCtrl."

have you configured just the same class name for each of 3 controls?

you will have to give them unique class names, that will as well help you to identify which one breaks the rule.

Badge +7

Thank you for your reply.

I have tried several different ways prior to creating this post, and have been unable to get your function to...well... function wink.png

Could you provide a more detailed example? ie. where to put your function and how to call it? 

Userlevel 5
Badge +14

does this help https://community.nintex.com/message/63336-re-number-of-attachments-based-on-calculated-field-value?commentID=63336#comm…  ?

Badge +7

thank you yes this does help! I was able to validate a with it.But shouldn't I be able use the number too? 

So I used 

GetNumberOfAttachments('attCtrl')<1

on a attachment control. With no attachment it catches it and displays the error. With an attachement it lets the process finish. So I know it's working. But I am not able to display the number no matter how many attachments the number remains '0.'

I have added 

GetNumberOfAttachments('attCtrl')

to calculated values and form variables but cannot get the number to change. 

Any ideas?

Userlevel 5
Badge +14

I'm not sure I understand what are trying to do...

do you want to display current number of files uploaded to a given attachment control, and do you want it to dynamically change once you add or remove one?

if so, then the reason is that this formula doesn't anyhow depend on that specific attachment control, hence it need not to recalculate once attachment control changes.

I wonder whether you really need it, or whether it was meant just as a kind of proof check to see how does it evaluate.

the problem is that attachment control is not listed among named controls, so it can not be directly referenced in calculation formula.

if you really needed to see current number of attached files, it would require some further scripting.

I've never investigated that so I'm not sure how complex it might be.

Badge +7

thank you for your response. 

Yes I guess I was trying to see how many were uploaded be for the form was submitted. But I also tried to save the number of attachments by linking it to a field and that did not work either. 

I have 3 attachment controls. They are not visible until after the form has been submitted, and a user returns to the form to upload documents. 

My end goal is to not validate the attachment control being empty until the user returns..... 

Oh wait... so I can use another "yes/no" field to add to the validation, switch it on submit then validate once the user returns! 

Does that make since? I guess I just needed to talk through it.

Userlevel 5
Badge +14

I think you do not need any further checkbox.

it looks like you want to apply validation only when user edits existing item, and not apply it when it creates new one.

if so the have a look on 'IsEditMode' common reference.

your formula then might look like

IsEditMode && GetNumberOfAttachments('attCtrl')<1
Badge +7

Marian Hatala - Should I be able to use an If() statement in a calculated column to save a "No" or "Yes" based on this script? I'm trying to use this variable in a workflow.

Ex: if(GetNumberOfAttachments('attCtrlAcc')<1,"No","Yes")

Userlevel 5
Badge +14

in workflow you can use ItemProperty:Attachments reference to determine whether an item have any attachment. you do not need to save it on your own.

it evaluates to true/false.

Badge +7

yes but I have multiple attachment controls... this example only says if any attachments are uploaded, not which control uploaded them.

I've got it worked out. So I have spoken to another Nintex expert Patrick Abel who explained that I can accomplish what I'm trying to do with an action set in a workflow. I can pull out the number of attachments per control and use that variable in the workflow. 

 

Thank you for your assistance.

Badge +8

Marian Hatala‌ to provide some additional context into the solution (and aid others in the future) – Josh Henderson‌ had multiple attachment controls on his form and needed a means (via Nintex Workflow) to determine if each of those controls independently had files uploaded. For instance:

  1. Attachments Control 1 has:
    1. someDocument.docx
  2. Attachments Control 2 has:
    1. someImage.png
    2. anotherImage.png

The ItemProperty:Attachments property will give you a boolean (Yes/No) if there are any attachments, but in Josh's case, he needed to know if any (or how many) documents had been uploaded to a specific attachments control in the form.

We started down a call web-service action path initially, but unfortunately the GetAttachmentCollection method doesn't expose which control is associated with each attachment.

However, I was able to accomplish what Josh Henderson was looking for by parsing specific nodes out of the ItemProperty:FormData XML. A Query XML action can be used to retrieve named attachment controls from FormVariables (see screenshot below):

This action results in a text variable output which contains each of your attachments with a semi-colon delimiter (i.e. someImage.png;anotherImage.png). You can then split on the delimiter into a collection, count attachments, and work with as needed. happy.png

Userlevel 5
Badge +14

I somehow understood ‌ needs to validate 3 separate controls on form, but just needs to identify an item has attachment in workflow.  and he haven't explicitly mentioned it should (still) be per single attachment control. maybe a problem of discussing several topic within one thread, I might have advised him to start a new question(s) for new topics and explain the exact requirements.

but ok, my bad happy.png

sure, I know which attachment was uploaded with which control could be determined from FormData happy.png

 

Badge +8

 completely understand! I was responding primarily so that if others find themselves in a similar boat, they won't run into dead-end threads. happy.png

Thanks!

Reply