Parent Hub association
Nowadays SharePoint hub sites can be associated to other hub sites, this is known as parent hub association. In this article I will show you how you can use a Power Automate flow for this.
This question from Adecnoc:
The flow has as its trigger a list with the various fields that are filled in and allow the creation of sites with the data that is passed.
Everything works fine, except for joining an hub site to another hub site (parent hub). When I try to do that, the flows stops with an error and says that the site is an hub yet and I can’t join to parent.
Power Users Community thread: Join Hub Site to another Hub Site.
Normally you have different options to associate a site collection to a hub site collection (aka hub association).
– SharePoint Admin Centre Active sites overview
– Site Information settings of the site itself
– The Add-SPOHubSiteAssociation (Microsoft.Online.SharePoint.PowerShell module) or Add-PnPHubSiteAssociation (PnP.PowerShell module) PowerShell cmdlets
– JoinHubSite REST API method
However, in this instance we wanted to associate another hub to the hub. Let’s have a look what options we have for that specific scenario?
Parent Hub association
The following options are available for hub to hub association (aka parent hub association).
– SharePoint Admin Centre Edit Hub Settings
– The Add-SPOHubToHubAssociation (Microsoft.Online.SharePoint.PowerShell module) or Add-PnPHubToHubAssociation (PnP.PowerShell module) PowerShell cmdlets
– CLI for Microsoft 365 hubsite connect command
– But no clear REST API method which we can use in Power Automate?
Or can we just try the JoinHubSite as well? Short answer, no. Seems like this method will keep trying until it fails.
GetById method & ParentHubSiteId property
Turns out that there is a method for this. The Microsoft Hub site REST API documents have a GetById method for the hub sites. And like the description says, this is for Gets or updates of individual hub sites.
After a bit of testing I saw a property called ParentHubSiteId is available (just like in the hub settings interface, lol).
Below is an example. I have used a couple of Initialize variable actions and one Send an HTTP request to SharePoint action. That action uses the below settings.
This uses the id of the child hub site (stored in the NewSiteId string variable).
The value of the ParentHubSiteId property uses the id of the parent hub site (stored in the HubSiteId string variable).
Et voilà, parent hub association completed!