使用ecmascript的sharepoint 2010写入列表
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用ecmascript的sharepoint 2010写入列表相关的知识,希望对你有一定的参考价值。
This code works for me without requiring any includes, plugins, or service packs. It should also integrate seamlessly with jquery.
ExecuteOrDelayUntilScriptLoaded(functionName, "sp.js"); //this is necessary to ensure the library is loaded before function triggered function functionName() { var clientContext = SP.ClientContext.get_current(); var myList = clientContext.get_web().get_lists().getByTitle('myList'); //actual list name here var itemCreationInfo = new SP.ListItemCreationInformation(); var listItem = myList.addItem(itemCreationInfo); listItem.set_item("Title", "the title"); //actual field names go in first argument, new assigned value in second listItem.set_item("Field2", "tuna"); listItem.set_item("Field3", "ape"); listItem.set_item("Field4", "moose"); listItem.update(); clientContext.executeQueryAsync(Function.createDelegate(this,this.Succeeded),Function.createDelegatethis,this.Failed)); } function Succeeded() { alert("Succeeded"); } function Failed(sender,args) { alert("fail"); } </script>
以上是关于使用ecmascript的sharepoint 2010写入列表的主要内容,如果未能解决你的问题,请参考以下文章
使用ECMASCRIPT从列表读取SHAREPOINT 2010
JavaScript SHAREPOINT 2010使用ECMASCRIPT从列表中读取
将SharePoint Online Client组件(Microsoft.SharePoint.Client)与powershell 2.0一起使用