Forum Discussion
Add-SPOSiteDesignTask : Operation is not valid due to the current state of the object.
Dinesh Bhat I'm not sure how much help I can be here. Whenever I've previously received the same error message that you've been receiving - "Operation is not valid due of the current state of the object" - it usually means that whatever I am attempting to edit or modify cannot currently be modified, for instance if it is already undergoing edits or changes. So whilst I don't think I'm able to suggest a fix for you, I might be able to help diagnose where things are going wrong.
To this end, do you have multiple site scripts interact with the same sections/functions/areas? Could this be where the issue is coming from?
Thanks, each list is separate there is no connection. I have tried with 7 list with 2 site scripts it works, if i add one more site script below error throwing
We have large site with more than 30 list and library. So we have split into 4 site scripts due to limit of 100000 characters. After we have added 4 site scripts into site using below code
Add-SPOSiteDesign `
-Title "My customer tracking" `
-WebTemplate "64" `
-SiteScripts script1.id,script2.id,script3.id,script4.id `
-Description "Tracks key customer data in a list" `
-PreviewImageUrl "https://contoso.sharepoint.com/SiteAssets/site-preview.png" `
-PreviewImageAltText "site preview"
After when we try to apply Add-SPOSiteDesignTask throwing below error
"Operation is not valid due to the current state of the object" any idea? how to resolve or root cause
- AronHNZSep 07, 2020Copper Contributor
Hi Dinesh, did you ever find a resolution for this issue? I am getting the same thing, I can split the scripts into more site designs an it will work , but then I need to trigger multiple site designs. the only other option is to have azure run the scripts, but that involves a premium license for HTTP requests in flow. or setting up a datagateway server on premise to run the script.
Cheers
**update**
I am getting the same issue running via Azure runbook as well. the only options i will be left with is adding the site design task via RestApi if i want to keep the large site design. or split to many site designs( as that works). Any help with this would be appreciated.
cheers