1,804 articles and 14,810 comments as of Saturday, April 2nd, 2011

EndUserSharePoint has combined resources with NothingButSharePoint.com. You can now find End User (Mark Miller), Developer (Jeremy Thake) and IT Pro SharePoint (Joel Oleson) content all in one place!

This site is a historical archive and is no longer being updated. Please update your favorites, bookmarks and RSS feeds.

NothingButSharePoint.com
Tuesday, January 12, 2010

Creating filtered lookups in SharePoint 2010 with InfoPath 2010

Guest Author: Toni Frankola
SharePoint Use Cases

One of the usual challenges with SharePoint 2007 was to build a lookup field between two lists but also apply a custom filter to the values being displayed.

Let’s consider a simple scenario: You have two lists on your site: Projects and Project Tasks. You want to link each task in Project Tasks list with a project in Projects list. This was simple even in v2007, you only had to create a lookup column and you were good to go.

But what if you wanted to link tasks with only active Projects (each project has a Yes/No column indicating if it is active), that was a bit more challenging.

Let’s check how you can solve the problem with SharePoint 2010 (Enteprise edition only). Here is what you need to do:

  1. On a SharePoint site create one custom list Projects with two columns: Title and Active (Yes/No column). You can add additional columns if you need them.
  2. Use Tasks list list template and create a list Project Tasks. Add one additional Lookup column connected to the Projects list (do not select “allow multiple values”)

SharePoint is going to create all the required forms for you. The default form for Project Tasks will look like this. The problem is, it shows inactive projects.


To change this, follow these steps:

  1. Open your list. In the List Tasks > List Ribbon click Customize Form button. You must use IE to use the button. You will perform form customization with InfoPath 2010.

  2. In the InfoPath form designer right click on Project field and click on the Drop-Down list properties option.

  3. On the newly opened dialog click Add button

  4. You need to create new connection to receive data from the Projects list. Select Create a new connection to: Receive Data. Click Next >.

  5. Select SharePoint library or list as your source. Click Next >.

  6. Type in the URL of your SharePoint site. Click Next >.

  7. Select the Projects list you created before. Click Next >.

  8. From the fields list, select the following fields: Title, and Active. Select to sort by Title. Click Next >.

  9. Click theNext button a few times to finalize this wizard. Once completed you will be taken back to the properties dialog.

    Select ID field as value field. Click the button Next to Entries field, then Select a Field or Group dialog should appear.

  10. On the Select a Field or Group dialog click on the Filter Data… button

  11. On the filter dialog, create a filter as shown on the picture below. This will force the drop down to load only active projects.


Close all dialogs and save the changed form. When you go back and try to create a new item in your list, the projects dropdown will only show active projects.



Conclusion

This article describes how you can create a filtered lookup for SharePoint 2010. It is easy to use and no code is required to make it work. A pure end user solution. There are some limitations: it does not resolve the problem of updating old Tasks that have already been assigned to inactive projects. It also only works with Enterprise edition. In future blog posts I will try to create some alternatives for SharePoint foundation.

Guest Author: Toni Frankola
SharePoint Use Cases

Toni started his Web adventure in late 90’s and has been working with various web technologies ever since. These days his main focus is SharePoint technology. He is active in the SharePoint community via his SharePoint blog at http://www.sharepointusecases.com/ and Twitter http://twitter.com/tonifrankola, and also speaks about SharePoint at various SharePoint conferences. Toni runs his own company Acceleratio Ltd., that specializes in SharePoint consulting and developing software products, and leads the Croatian SharePoint User Group. 

 

Please Join the Discussion

9 Responses to “Creating filtered lookups in SharePoint 2010 with InfoPath 2010”
  1. Mickoni says:

    I’v been looking a long time for something like this to work without the use of any coding.
    Will this also work with SP2010 and Infopath2007?

  2. @Mickoni: Nope, you need InfoPath 2010 to customize forms. These are transformed to web pages on SharePoint server so your users do not need InfoPath.

  3. Hi,
    very nice tutorial. i found this site, when i was looking for creating sharepoint filtered lookup field from visual studio. i post link to the blog where is described creating such as field for people with the same problem who find this site like me.

    http://sharepoint-brandon.blogspot.com/Sharepoint Filtered Lookup Field

  4. Dave says:

    If you create your list in SharePoint as a Form Library (only available for SP2007 with MOSS) you can do this with SP2007 as well.

    Just create the Form Library in SharePoint (your “Project Tasks”), then go to InfoPath and design a form. When publishing, choose to publish to an existing Form Library, and tie the fields from your Form to the existing columns in the Library.

    The binding of data from the “Projects” list to a control in InfoPath will be exactly as you’ve shown, although this prohibits the form from being opened in-browser (it will open in InfoPath, requiring all of your users to have InfoPath installed).

  5. Subroto says:

    I tried all the steps in your tutorial but whenever I open any list in InfoPath and then reupload (publish) it to SharePoint 2010, I get some JS error and clicking on Add New Item shows the pop up but with the ribbon which again is completely grayed out. Also there are no text boxes to choose from or anything. Do you know what the possible issue might be with this?

  6. Prashant says:

    I am able to do this with single value lookup columns. But Is it possible to do this with multivalue lookup columns?

  7. leonita says:

    hiii…
    im new in both sharepoint n infopath..i try to make a request form …it have many detail (requester can ask many items)..
    my questions is
    1. if i want to create that form, it use List or Library ?? (now i use library coz i using a repeating table, am i wrong? )
    2. can we filtering data by parameter in infopath?? i hv form with repeating table, textbox input (for searching key), and a button (for query)…when user click the button, it will be querying data depends on wht user input in textbox and return the value to the repeating table…

    can someone help me…

    Thanks,
    leonita

Trackbacks

Check out what others are saying about this post...
  1. SharePoint 2010 Beta Joining Modern Web Age; Google Exit Threatens Chinese Internet; Google vs. SharePoint…

    Top News Stories REVIEW: Microsoft SharePoint 2010 Beta Brings Already Solid Server into Modern Day …




Notify me of comments to this article:


Speak and you will be heard.

We check comments hourly.
If you want a pic to show with your comment, go get a gravatar!