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.
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
Could you provide a more detailed example? ie. where to put your function and how to call it?
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?
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.
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.
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
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")
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.
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.
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:
- Attachments Control 1 has:
- someDocument.docx
- Attachments Control 2 has:
- someImage.png
- 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.
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
sure, I know which attachment was uploaded with which control could be determined from FormData
completely understand! I was responding primarily so that if others find themselves in a similar boat, they won't run into dead-end threads.
Thanks!