Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I want to create a new site in a SharePoint Online (Office365) sitecollection. When I was looking for information in the msdn it was saying that this stuff is not available in sandboxed solutions.

Anyway I found the project iLove Sharepoint and the description says: "With this set of actions you can easily create new sites and assign permissions to them. And the best thing is, this works in Office 365 too!"

Is it possible to create a new SharePoint site (from template) in a sandboxed solution? And if it is, how can I do it?

share|improve this question

2 Answers 2

The right answer is to create your custom web templates in VS and deploy them as WSPs. That way you control the IDs.

However, if you need to get the IDs of site templates that already exist and you don't want to go through that process, you could create a solution with a simple web part that calls SPSite.GetWebTemplates(LCID) and spits out the Name (what you're looking for) and Title of each template. That method is supported in SharePoint Online. Deploy the web part to your online site, throw it on a page, and grab what you need from the results.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsite.getwebtemplates.aspx

At that point, you can create the site using the following,

SPWebTemplate template = site.GetWebTemplates(nLCID)[projectTemplateName];
newWeb = web.Webs.Add(newProjectId, newProjectId, "", nLCID, template, false, false);

Source [site]

share|improve this answer

It is possible to create a new site (SPWeb) from template in a sandboxed solution. You can call currentWeb.Webs.Add. In that method you can specify the template of your site, but you have to know the name of your template.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.