I have a 2010 sandboxed solution for an action I use in a workflow. The action runs as an impersonation step and creates a subsite based upon a user inputting a new item into a list. This is running as a sharepoint 2010 workflow on SharePoint Online 2013.
When the code runs it returns the error "The Web site address "/sites/Management/ATEST" is already in use." Every time, even if it is a new site url. I altered the code to borrow from MSDN and check to see if the site already exists before the subsite is created. (Code from http://msdn.microsoft.com/en-us/library/ms412285.aspx). Each time it returns that the site exists. Site Contents lists nothing - and a Content and Structure Report lists nothing as well.
SPSite currentSite = null; //current site collection. SPWeb currentWeb = null;//current web site in the collection. SPWeb newWeb = null; //the new one to be created. try { currentSite = new SPSite(context.CurrentWebUrl); currentWeb = currentSite.OpenWeb(); //if a child site already exists open it // If a subsite by that name exists, open it. string[] webs = currentWeb.Webs.Names; if (webs != null && Array.IndexOf(webs, url) >= 0) { newWeb = currentWeb.Webs[url]; } if (newWeb == null) { newWeb = currentWeb.Webs.Add(url, title, description, (uint)language, spTemplate, uniquePerm, false); }
With the altered code it finds the child site and returns the link to it. When clicked on there is nothing there since the addsite never ran. Has anyone run in to this yet on 2013?
Is there a new way to handle these situations 2013? The end result I am looking for is to allow a user to add an item to a list, and when the item is added - build a subsite from a template then edit a link column in the just added list item to point to the URL of the shiny new child site.