Thursday, June 6, 2013

InfoPath Drop Downs using SharePoint 2013 REST

Ever had the need to map a choice field to a drop down list in InfoPath?
SharePoint REST API makes this super easy! gone are the days of Lookup Lists and Lookup Columns. No need to maintain two sets of values either!

A rather unknown feature of SharePoint 2010 onwards is the fact that the REST interface, the one you access via /_vti_bin/listdata.svc, also gives you access to your choice fields in a simple XML format. Effectively the new choice field becomes a new entity at the same level as the list/library with a concatenated name.
So if you list is called Customers and the choice field is called Region, the url would look as such:
/_vti_bin/listdata.svc/CustomersRegion
SharePoint will spit a RSS formatted feed back out at you with all the choices listed :-)

All you need to do now is go to your InfoPath form, create a new data source, select REST Web Service as the source and paste the url to the choice list. Press OK and Finish, and now you can use that data source for your drop down values by:
  • Modifying the Drop Down List Box Properties
  • Choose  Get values from an external data source
  • Pick the REST data source
  • For Entries source pick /ns1:feed/ns1:entry
  • For Value and Display Name pick ns1:title
Done! you now have an InfoPath drop down list powered dynamically by your SharePoint Choice field!

2 comments:

Berbagi Bersama said...

nothing error but i can't see my dropdownlist it not display . can you help me ?

Alex Dean said...

Sorry mate. without an error message I can't predict why it would not work for you.