Load lists from a different site on PropertyFieldListPicker control

The latest release of PnP Reusable property pane controls (1.8.0) adds an additional property (webAbsoluteUrl) that allows a target site to be specified for loading the lists.

Information Architecture

While nowadays, the trend is to not use sub-sites – at the moment you can’t even create a modern SharePoint site as a sub-site, in the past, the sub-site approach was commonly adopted by organisations when planning the Information Architecture of SharePoint sites. Using this approach, it was common to see information stored at the root web level (on custom lists) being used on sub-sites.

A different approach would be to use multiple site collections, where one of the site collections was often used as a central repository of information that would be consumed by the others.

The problem

If you have a project that follows one of the models described above, you were not able to use the PnP PropertyFieldListPicker control on your SharePoint Framework web parts to load data from a different site.

The PropertyFieldListPicker was initially built to load the lists of the current site by default, and it was not possible to specify a different target site.

1.8.0

The changes included on the 1.8.0 version introduce a new optional property (webAbsoluteUrl) that allow you to specify the web absolute url of the target site to load the lists from.

This can be as simple as:propertyFieldListPicker

In this example we use the current web from the page context, which you really don’t need as that’s the default behavior, but you get the point.

One important thing to keep in mind is that you need to ensure that the users have permissions to access the list if the list is on a separate site/site collection.

 

Leave a Reply