InfoPath 2010 – Validating the Attachments Field

InfoPath 2010 has its ups and downs. For the most part it makes things extremely easy. However, you’ll still run into the occasional roadblock while working with InfoPath forms.

I recently ran into one such roadblock. The issue was being able to apply validation rules to the attachments field. To my surprise, InfoPath does not let you select the Attachments field to apply rules, making it a challenge apply validation on attachment fields. Also, if you go into the advanced view and select the repeating ‘:attachmentURL’ field inside of the Attachments group and apply formatting to that field it just doesn’t work.

So, I had to come up with a custom solution. Now, given one of the major advantages of using InfoPath in the first place is not having to use any code behind, I didn’t want to have to add custom code to my form.

My solution involves 3 steps:

1.) Create a field in addition to the attachments field. In my case, I called the field I created Attachment Validation.

2.) Drop your field onto the form and remove the borders and background. Then set the default text to ‘Attachments:’

InfoPath 2010 Attachments Field Validation

3.) Finally, lets apply some validation to this field. Right click the field on your form and select Rules > Manage Rules.

In my case, I needed to make sure there was at least one attachement. So, I counted the :attachmentURL instances and checked if there were more than 0. To do this, I used a custom expression:

Now with all of that complete you will have a separate field that validates the attachments field and if there are no attachments, the text in the left hand column will be surrounded in the standard red dashed border.

InfoPath 2010 Validation on Attachments Field


To get to the ‘:attachmentsURL’ field you need to create the validation make sure you go into Advanced View of the fields.

InfoPath 2010 Attachments :attachmentURL field advanced view

  1. really a good post
    That was! what I was looking for…

    • Martina
    • June 3rd, 2013

    Great info, Max. I’ve reposted on my blog so I don’t forget how to do it!

    • franslin
    • June 7th, 2013

    Can you please give it in clear

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: