SharePoint JavaScript 更新用户和组字段
前言
最近,需要更新列表字段,字段的类型是用户和组,so写了这么一段代码
function updateUserField(){ var ctx = new SP.ClientContext.get_current(); var list = ctx.get_web().get_lists().getByTitle('My List'); var item = list.getItemById(1);//Item Id var assignedToVal = new SP.FieldUserValue(); assignedToVal.set_lookupId(12);//User Id in the site collection item.set_item("AssignedTo",assignedToVal);//AssignedTo is a column name item.update(); ctx.executeQueryAsync( function() { console.log('Updated'); }, function(sender,args) { console.log('An error occurred:' + args.get_message()); } ); } ExecuteOrDelayUntilScriptLoaded(updateUserField, "sp.js");
博文推荐: |
SharePoint 2013 WebPart 管理工具分享[开源] |
基于SharePoint 2013的论坛解决方案[开源] |
SharePoint 2013 学习基础系列入门教程 |
SharePoint 2013 图文开发系列之门教程 |
SharePoint Designer 学习系列入门教程 |
特:如果有SharePoint项目,欢迎邮件联系我,Email:linyu_s@163.com |