Tuesday, November 1, 2016

How to export OTB List view web part and use it in different sub site in Sharepoint

As you probably know in Sharepoint it is possible to add standard List view web part on the page which is located on the same site with referenced list or doclib. But what if we need to use List view web part for displaying list from other sub site (not the one where web part is added)? By default it is not possible but after several additional steps it become possible. Here are these steps:

  1. Create new test page on the site where referenced doclib is located
  2. Add list view web part for appropriate list and publish the page
  3. Open page in Sharepoint designer
  4. Detach page from page layout
  5. Edit the page and change <ExportControlledProperties> property from False to True
  6. Save the page in Designer
  7. Go back to browser and edit the page. Now Export option will be available for List view web part
  8. Export web part to local file system
  9. In browser open other sub site where you need to add exported web part
  10. Open developer tools panel and in Console tab execute the following javascript code for getting id of the current web:
  11. Copy web id from output
  12. Open exported .webpart file and find <WebId> property. After export it will contain empty guid: 00000000-0000-0000-0000-000000000000
  13. Replace it with guid copied from developer console and save .webpart file
  14. Now again in browser go to sub site where you need to add exported web part and edit the page where web part should be added
  15. Click Insert web part in some web part zone and click Upload web part. Choose modified .webpart file
  16. After upload again click Insert web part on web part zone and choose web part from Uploaded web parts category

In result you will have OTB List view web part working with list from other sub site.

No comments:

Post a Comment