Tuesday, 4 December 2012

HOW TO MAKE AN ATTACHMENT A REQUIRED FIELD IN INFOPATH FORM


I. INTRODUCTION

For today, I was asked by my project manager to modify an existing infopath form. The requirement is to make the attachment a required field in the infopath form. I thought that this is an easy thing to do as I have already experienced making a textfield required in an infopath form. For a normal textfield, this can be done by ticking the ‘Cannot be blank’ checkbox in the Validation tab.
In an attachment field, this will have a different approach and this is what I will discuss on this post.

II. SCOPE

This post assumes that the reader already knows how to create a custom list in sharepoint 2010. It is also required that the reader knows how to customize the layout of the sharepoint list form by using Infopath. A good post about doing this is located on this site. ( http://msdn.microsoft.com/en-us/library/office/gg180738(v=office.14).aspx )

III. REQUIREMENTS
- Sharepoint 2010
- Infopath Form

IV. IMPLEMENTATION

1. Navigate to
http://<your site collection>/ in your browser.
2. Navigate to your list and open the list form in the Infopath Designer 2010.

To open the list form in the Infopath 2010 Designer
1. On the List tab of the ribbon, Click Customize form as shown in Figure 1.

Figure 1. Customizing the list form


2. We will focus our attention in the attachment control. Drag the attachment field into the canvas and add a label ‘Attachment’ beside it.

Figure 2. Attachment field


3. To make the attachment field required, we will add a dummy textbox control that will contain the required rule. To do this, add a textbox control and place it before the attachment field.

Figure 3. Textbox in attachment field


4. Right click on the textbox control, hover on ‘Rules’ and click on Manage Rules.

Figure 4. Manage Rules on textbox


5. Create a rule for the textbox. Click on the ‘New’ rule button and click on Validation. Add a name to your rule. On the Condition window, Select the ‘Attachments’ field and on the condition, select ‘Is Blank’.

Figure 5. Condition window

  
6. Create another rule to hide the textbox. Click on the ‘New’ rule button and click on Formatting. Tick on the checkbox ‘Hide this control’.

Figure 6. Hide the control


7. That’s it! We are done. Try to add an item to the list and try to not add an attachment. The save operation should fail. The infopath should raise an error indicating that a required attachment field is empty.

1 comment:

Anonymous said...

The King Casino Online
You can play at The https://septcasino.com/review/merit-casino/ King Casino with over 3,000 free spins, This casino game is https://access777.com/ the perfect fit gri-go.com for both entertaining players and high-quality 1xbet korean online 바카라 사이트 casino players.

Oscar L. Barit Jr. "I am Oca, i am writing to share with you some sharepoint matters that i learned on my day job. Enjoy! Mwah Mwah Tsup Tsup! "