Display Data From Other List in a List Form Using REST

This article explains a way to display some list data in another list’s New / edit form customized using InfoPath, using REST services.

Here in this example, we have a list called Tracker and another list - Configuration.

In the new form of Tracker, we want to display a particular row’s data from Configuration list.

This row would give information to the user who is filling the tracker, that for the current week, the review would be done for a particular division (this data is updated by some admin in the configuration list)

Here is the structure of the main list - Tracker.

Tracker

Here is the structure of the configuration list. Please note that the details you want displayed on the other’s list’s form - cannot be of type choice / lookup. InfoPath doesn’t handle these types in REST queries.

structure of the configuration list

I have 3 rows of data in the Configuration list. The admin enters /updates the list, say every week.

Configuration list

In the Trackers’ form, we want to display the most recent ( by week) data. That is display a message that the division that is to be reviewed in the “3rd week of December “ is “Admin”. This message would need to be displayed at run time - bringing the latest value from the configuration list.

Now, let us customize the Tracker list’s “New Form” using InfoPath as shown below.

Tracker lists

1. When the form opens in InfoPath designer, click on the “Manage Data Connections” link as shown below.

InfoPath designer

2. Click on the Add button to add a new data connection.

Add InfoPath designer

3. Ensure this is a connection to receive data

receive data InfoPath designer

4. Select the source for the data to be a REST web service as shown here.

REST web service InfoPath designer

5. Enter the REST service details in the following format:

http://<YourSharePointSite>/_vti_bin/listdata.svc/<ListName>/?$select=<Field1>,<Field2>&$orderby=<Field>&$<other filter criteria>
In my case, it is

http://<MySite>/_vti_bin/listdata.svc/Configuration/?$select=Title,Week,ReviewDivision&$orderby=Week desc&$top=1

Configuration – the name of the list from where I want to get the details to be displayed in my Tracker’s form

Title,Week,ReviewDivision – the fields that I need to display in the form

Week desc – I want to order by desc Week

top=1 – and get the first item after ordering – that is the latest week’s data

REST web service1

6. Verify that the REST URL formed in the previous step works fine by entering the url in a browser and check if the required data is returned

REST web service2

7. Now, provide a name to this connection and complete the data connection wizard

REST web service3

8. Once the REST data connection is created, switch to the advanced view in the InfoPath form designer as shown here.

REST web service4

9. In the advanced view, choose the REST service created in the previous step

REST web service5

10. Verify that the fields specified in the REST url are visible here. Mind the previous warning that fields of type - lookup, choice etc will not be supported. Although in the URL formation, there will be no error, those fields will not appear here.

REST web service6

11. Drag and drop these fields on to your form

REST web service7

12. And format the form as you like.

REST web service8

13. Publish the form to the list by using the “Quick Publish” menu

REST web service9

REST web service10

14. Now, when we try accessing the list and create a new record in the Tracker list, we see the intended message - that the “Review Division” for the “3rd Week of December” is “Admin”, as shown below.

REST web service11