Sharepoint托管的应用程序

时间:2013-08-29 21:30:48

标签: sharepoint sharepoint-2013

我正在尝试使用带有自定义模板的SP在线网站中的Javascript客户端对象模型在我的sharepoint托管应用中创建一个网站。

问题:我可以在sharepoint托管应用中执行此操作吗?如果是这样,请提供一些例子。

这是我的代码

this.context = SP.ClientContext.get_current();
this.web = context.get_web();

// Build out the WebCreationInformation for the new site
var wci = new SP.WebCreationInformation();
wci.set_title('My New Web Site 2');
wci.set_description('Description Input');
wci.set_url('mynewwebsite7');
wci.set_language(1033);
wci.set_useSamePermissionsAsParentSite(true);
wci.set_webTemplate('STS#1');

// Create the new web in the client context
this.childWeb = this.web.get_webs().add(wci);
this.context.load(this.web);
this.context.load(this.childWeb);//, 'ServerRelativeUrl', 'Created');

// Now create it on the server
this.context.executeQueryAsync(Function.createDelegate(this, this.createSiteSucceeded),
                      Function.createDelegate(this, this.createSiteFailed));

1 个答案:

答案 0 :(得分:0)

this.web = context.get_web();

// Build out the WebCreationInformation for the new site
var wci = new SP.WebCreationInformation();

你不能在你的代码中写这个。您必须首先加载requestexecutor.js然后进行客户端上下文或其余的API调用以获得所需的结果。你也必须在appmanifest中完全控制网站集。

相关问题