➜ m365 spo homesite set throwing Error: Operation is not valid due to the current state of the object.
Priority
(Low) Something is a little off
Description
The cmdlet m365 spo homesite set -u https://reshmeeauckloo.sharepoint.com/sites/contosoportal is throwing "Error: Operation is not valid due to the current state of the object."
Steps to reproduce
Go to Office 365 admin center -> Settings -> Viva -> Viva connections Ensure there are multiple Viva Connections. In my instance I have
- https://reshmeeauckloo.sharepoint.com/sites/contosoportal
- https://reshmeeauckloo.sharepoint.com/sites/TheLanding
m365 spo homesite set -u https://reshmeeauckloo.sharepoint.com/sites/contosoportal is throwing "Error: Operation is not valid due to the current state of the object."
Expected results
The home site is set without any errors thrown
Actual results
The home site is not set and error"Error: Operation is not valid due to the current state of the object." is thrown
Diagnostics
No response
CLI for Microsoft 365 version
v7.9.0
nodejs version
v20.8.1
Operating system (environment)
Windows
Shell
PowerShell
cli doctor
No response
Additional Info
No response
I can work on the bug after it has been reviewed.
Thank you for reporting this @reshmee011, your help is much appreciated!
@reshmee011 since it's possible now to specify more than one home site, do you think it would make sense to rename the command to spo homesite add?
spo homesite add will add another homesite which can be a different cmdlet definitely and spo homesite set will update an existing home site with additional values.
If there multiple viva connection experiences are enabled at the tenant, i.e. Tenant Property "IsMultipleVivaConnectionsFlightEnabled", the endpoint UpdateTargetedSite is called. Otherwise SetSPHSiteWithConfiguration is called with the additional properties DraftMode.
Thank you @reshmee011, sounds like a plan. Let's get this command fixed and see if we can implement a spo homesite add command as well.
This would mean that the option vivaConnectionsDefaultStart will have to be required for the spo homesite set command. (breaking change so that's for V8).
@reshmee011 are you still working on this?
@milanholemans: hope you are doing fine. I work on one PR at a time , I am just waiting for the PR I created to be merged before starting to work on this one. Happy to let someone else work on it. I’ll pick up another issue once my current PR is merged.
Ok, thank you for letting us know. We had a lot of open PRs, but the amount is gradually dropping. We'll try to pick up your open PR ASAP.
@milanholemans: I have started working on the fix. The endpoint to update the home site properties will be UpdateTargetedSite instead of SetSPHSite. There are additional properties that can be supported like audiences properties, draftmode, order. https://learn.microsoft.com/en-us/viva/connections/set-up-admin-center. Shall I write a better spec for review that would work with UpdateTargetedSite endpoint?
I could not spot when the endpoint SetSPHSiteWithConfiguration will be called with vivaConnectionsDefaultStart parameter anymore. Let me know if you are able to find anything.
Since SharePoint home sites are now quite related to Viva Connections, I'm wondering if we should get rid of the spo homesite commands and move them to viva connections commands. What do you think @pnp/cli-for-microsoft-365-maintainers?
@milanholemans : I will wait for further direction how to approach the fix as it is a full refactor of the functionality to work with the changes of home site linked to viva connections.
Since SharePoint home sites are now quite related to Viva Connections, I'm wondering if we should get rid of the
spo homesitecommands and move them toviva connectionscommands. What do you think @pnp/cli-for-microsoft-365-maintainers?
To me, they're independent. You define the home site separate of VC. I vote we keep them separate.
In the UI, when you want to set up a home site, you are redirected to the Viva Connections admin page. But all right, let's keep it separate.
@milanholemans : How shall we proceed? Start with writing the specs how to fix the bug with the endpoint UpdateTargetedSite with a follow up cmdlet to add home site using the endpoint AddHomeSite?.
@milanholemans : How shall we proceed? Start with writing the specs how to fix the bug with the endpoint UpdateTargetedSite with a follow up cmdlet to add home site using the endpoint AddHomeSite?.
Looks like a good idea indeed. Thanks.
@reshmee011, this issue is a duplicate of #6489, right?
Yes it is duplicate, this one is for the bug and #6489 for enhancement.
Ok since we will fix it in #6489 anyway, let's close this one.
Sounds good. Happy for it to be closed.