I'm trying to set up a cross-site lookup field with XML (which I've been able to do in previous SharePoint On-Premises environments). However, I have some issues with creating a similar configuration in my tenant-based SharePoint Online environment.
My destination configuration contains the following details:
- Two (modern) team sites, both at the same site level and both linked to one
Team (Hub) Site.
- SiteA has a list of projects / products.
- SiteB has a list of records that contain a search box that needs to point to the project list on SiteA.
For now, I'm just trying to create a site column on SiteB, which is a search box that points to the project list on SiteA. Knowing that this configuration can not be done in the OOB UI, I use PowerShell 5.1 commands and PnP library cmdlets to do this via XML. When I run the following lines, SiteB creates a site column that does not appear to be connected to the project list (SiteA). So when I use them to create a column in a list, there are no values. I also tried to directly create a column in a list (to see if that would work better).
In the following XML file, I specify the GUID of the list on SiteB, which contains the list of projects and the Web Site Web context GUID. I am using NewGuild to generate a new GUID for the new site column.
Some examples of my PS code:
$newguid = (GUID)::NewGuid()
$fieldXML = ''
Add-PnPFieldFromXml -FieldXml $fieldXML
One thing I noticed (and that puzzled me) is that when I use Get-PnPWeb to get the WebID (which I believe), the returned GUID for SiteA and SiteB are exactly the same. I've used separate PowerShell consoles to extract information for the sites separately to make sure the commands run on the right sites. So I'm wondering if I'm using the right GUID in my XML code (for WebId) to point to the web (or site) that contains the project list.
I'll keep trying, but I hope someone has some suggestions or insights about configuring XML for SharePoint Online and successfully setting up cross-site search.
UPDATE on the original question
I have continued to work on this topic. I've worked with two team sites, both of which are mapped to a hub site. But then I decided to work with two different team sites – which are not associated with any hub sites. In this case, the WebIDs (LookupWebIDs) were different. So I reconfigured my XML and used Add-PnPFieldFromXML, which created a new site column (no errors) and checked out the property values for the new column as needed.
$fieldXML = ‘’
Add-PnPFieldFromXML -fieldXML $FieldXML (to create the new Test Column on Site A)
PS C:> $testCol.LookupList
PS C:> $testCol.LookupWebID
But when I tried to use the new column in a list – the pulldown has no values (should be 3 values) – it still does not seem right to connect to the list on another site.
UPDATE 2 – One possible solution
Finally, using PowerShell / GUID / XML, I was able to get the cross-site function to set the SchemaXML property of a search box in my list (SiteB) to point to a list of values (SiteA). GUIDs for List, WebID, and SourceID were set to cross-site values, and everything worked as expected. However, I first had to create a classic site collection (in my online tenant) so I could then create two team sites using the classic SharePoint Team Site template.
Regardless of what I tried, I could not use the cross-site feature for a Modern Team Site template. For me, it only seems to work in sites created with the Classic template. It is still important to find a solution that enables a multi-site search with the Modern configuration. Therefore, this problem is still unresolved. I just wanted to share what worked – just in case it helps someone else.