[SharePoint 2013] Set value for people editor with JSOM
function PeoplePicker() {
this.context = null;
this.web = null;
this.currentUser = null;
this.parentTagId = null
this.SetParentTagId = function (id) {
this.parentTagId = id;
}
this.SetLoggedInUser = function () {
if (this.parentTagId != null) {
this.getWebUserData();
}
}
this.getWebUserData = function () {
this.context = new SP.ClientContext.get_current();
this.web = this.context.get_web();
this.currentUser = this.web.get_currentUser();
this.currentUser.retrieve();
this.context.load(this.web);
this.context.executeQueryAsync(Function.createDelegate(this, this.onSuccessMethod),
Function.createDelegate(this, this.onFailureMethod));
}
this.onSuccessMethod = function () {
this.setDefaultValue(this.currentUser.get_title());
}
this.onFailureMethod = function () {
alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
}
this.setDefaultValue = function (value) {
var parentTag = document.getElementById(this.parentTagId);
if (parentTag != null) {
var _ppe = $("input[title='" + $(parentTagId).attr('title') + "']");
_ppe.val(value);
var _ppo = SPClientPeoplePicker.SPClientPeoplePickerDict[this.parentTagId];
_ppo.AddUnresolvedUserFromEditor(true);
}
}
}
function SetWebUserData() {
var pplPicker = new PeoplePicker();
var controlId = $('td.ms-formlabel:contains("field name")').siblings('td').find('div[title="field name"]').prop("id");
pplPicker.SetParentTagId(controlId);
pplPicker.SetLoggedInUser();
}
$(document).ready(function(){
ExecuteOrDelayUntilScriptLoaded(SetWebUserData, "sp.js");
});
[SharePoint 2013] Set value for people editor with JSOM的更多相关文章
- Device Channels in SharePoint 2013
[FROM:http://blog.mastykarz.nl/device-channels-sharepoint-2013/] One of the new features of SharePoi ...
- Creating a Custom Page Layout in SharePoint 2013
Creating a Custom Page Layout in SharePoint 2013 In my last article, I documented how to create a Ma ...
- Creating a New Master Page in SharePoint 2013
Creating a New Master Page in SharePoint 2013 This article explains how to create a Master Page in S ...
- SharePoint 2013 create workflow by SharePoint Designer 2013
这篇文章主要基于上一篇http://www.cnblogs.com/qindy/p/6242714.html的基础上,create a sample workflow by SharePoint De ...
- Install and Configure SharePoint 2013 Workflow
这篇文章主要briefly introduce the Install and configure SharePoint 2013 Workflow. Microsoft 推出了新的Workflow ...
- SharePoint 2013 configure and publish infopth
This article will simply descript how to configure and publish a InfoPath step by step. Note: To con ...
- 沙盒解决方案解决SharePoint 2013 以其他身份登陆的问题
众所周知,SharePoint 2013没有像SharePoint 2010那样有一个叫"以其他身份登录"的菜单项. 当然解决方案也很多,比如你可以直接修改Welcome.ascx ...
- 实现一个基于 SharePoint 2013 的 Timecard 应用(中)
门户视图 随着 Timecard 列表的增多,如何查找和管理这许多的 Timecard 也就成了问题.尤其对于团队经理而言,他除了自己填写的 Timecard,还要审核团队成员的 Timecard 任 ...
- 实现一个基于 SharePoint 2013 的 Timecard 应用(上)
在 SharePoint 2013 上面实现一个 Timecard 应用的想法来自一个真实的需求,而实现的方案在我脑海里面盘旋已经很久了,终于这几天准备安排点儿时间将它实现出来. “ We start ...
随机推荐
- [BI项目记]-搭建代码管理环境之创建团队项目
此篇主要介绍如何基于TFS环境创建团队项目来进行项目代码的版本管理工作,这一系列将侧重于BI项目,当然对于其它项目也同样适用. 在TFS里开始一个项目,我们首先需要创建一个团队项目. 在Team Ex ...
- UVA 11481 Arrange the Numbers(组合数学 错位排序)
题意:长度为n的序列,前m位恰好k位正确排序,求方法数 前m位选k个数正确排,为cm[m][k],剩余m - k个空位,要错排,这m - k个数可能是前m个数中剩下的,也可能来自后面的n - m个数 ...
- 如何设置让基于matplotlib的绘图库正常的显示no-ascii字符(中文字符)
添加一句: import matplotlib matplotlib.rc('font', family='simhei') 其中family直接指示字体名字就行,比如simhei 注意:如果不能正常 ...
- MIT 6.828 JOS学习笔记4. Lab 1 Part 2.1: The Boot Loader
Part 2: The Boot Loader 对于PC来说,软盘,硬盘都可以被划分为一个个大小为512字节的区域,叫做扇区.一个扇区是一次磁盘操作的最小粒度.每一次读取或者写入操作都必须是一个或多个 ...
- CSS3动画效果-7.13
例如: <body> <div class="div1"></div> </body> CSS: @keyframes myfirs ...
- mysql 导入导出csv
导出: select RESOURCE_ID_INT,RESOURCE_ID_CHAR,RESOURCE_TITLE from t_resource_info_wb into outfile '/us ...
- ZeroMQ接口函数之 :zmq_getsockopt – 获取ZMQ socket的属性
ZeroMQ API 目录 :http://www.cnblogs.com/fengbohello/p/4230135.html 本文地址 :http://www.cnblogs.com/fengbo ...
- FP error code老是忘记的看这里:只给出最常用的几个。
把常见的几个记牢,不要在比赛时纠结. 错误2:输入文件未找到. 错误106:数据读入的格式错误,往往是读入语句出错. 错误200:被零除. 错误201:范围检查错误,数组越界. 错误202:栈溢出. ...
- Azure Active Directory Connect密码同步问题
这几天一直在弄O365与本地域账号的密码同步问题.由于微软即将用Azure Active Directory Connect(以下简称AADC)这个同步工具替代之前的DirSync,所以我也研究了下这 ...
- php ajax请求和返回
define('NOW_TIME', $_SERVER['REQUEST_TIME']); define('REQUEST_METHOD',$_SERVER['REQUEST_METHOD']); d ...