Monday, August 12, 2013

InfoPath forms for list views

In this post we are going to see how we can design different InfoPath forms for different views for SharePoint list.

We will consider one list and we will customize the list in InfoPath form. Many times we may have a requirement of showing different InfoPath form when you are viewing an item than when you are inserting or editing an item. Usually on view form you do not need any validation controls to be a prt of form when the form is customized in InfoPath. 

When you are inserting an item or editing an existing item, you need a rules that may be applied to a textbox which shows and hides some error or validation messages.

We will take very simple scenario of one single line of text and one choice column in the list. We will customize that form in InfoPath. What we essentially want is we will give some instruction below the control on InfoPath form to indicate what is expected from user from that control input.

 This will be a plain text that we will write because we do not have a label control as such in InfoPath. We also do not want to have textbox control inserted as we are not working with any rules validation.

This example will clearly highlight how we can define different InfoPath form for various view.
I have a list with two columns. Default title and country with choice column.

Now I am going to click on customize this list in InfoPath from ribbon.



When it opens up, write down some instruction below title and country.



and then publish the form. Once published, open up the list and create couple of items in it.



Now observe that as we have written some instruction below the controls, it appears when we insert or edit the item.

Now let's view an item.



As you can see that this experience is not what we require. Why would user be shown the same instruction when user is just viewing an item.

What we have to do first is create a replica of the entire edit form first and create a new view for the list in InfoPath.

So click on new view and give view a name.



Copy everything from edit item view of InfoPath and paste it on the new view that we just created. Remove the instruction this time.



Publish the form.

Now click on the form web parts option from ribbon



Now click on Item Display form option

Once you click on it, you will get this on the page



Now edit the web part and select the view to view item.



Click apply, ok and then stop editing.

Now click on any of the item in the list to view it.


and see the difference.

I hope this helps. 

No comments:




Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com