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的更多相关文章

  1. Device Channels in SharePoint 2013

    [FROM:http://blog.mastykarz.nl/device-channels-sharepoint-2013/] One of the new features of SharePoi ...

  2. 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 ...

  3. 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 ...

  4. SharePoint 2013 create workflow by SharePoint Designer 2013

    这篇文章主要基于上一篇http://www.cnblogs.com/qindy/p/6242714.html的基础上,create a sample workflow by SharePoint De ...

  5. Install and Configure SharePoint 2013 Workflow

    这篇文章主要briefly introduce the Install and configure SharePoint 2013 Workflow. Microsoft 推出了新的Workflow ...

  6. SharePoint 2013 configure and publish infopth

    This article will simply descript how to configure and publish a InfoPath step by step. Note: To con ...

  7. 沙盒解决方案解决SharePoint 2013 以其他身份登陆的问题

    众所周知,SharePoint 2013没有像SharePoint 2010那样有一个叫"以其他身份登录"的菜单项. 当然解决方案也很多,比如你可以直接修改Welcome.ascx ...

  8. 实现一个基于 SharePoint 2013 的 Timecard 应用(中)

    门户视图 随着 Timecard 列表的增多,如何查找和管理这许多的 Timecard 也就成了问题.尤其对于团队经理而言,他除了自己填写的 Timecard,还要审核团队成员的 Timecard 任 ...

  9. 实现一个基于 SharePoint 2013 的 Timecard 应用(上)

    在 SharePoint 2013 上面实现一个 Timecard 应用的想法来自一个真实的需求,而实现的方案在我脑海里面盘旋已经很久了,终于这几天准备安排点儿时间将它实现出来. “ We start ...

随机推荐

  1. 基于Libevent的HTTP Server

    简单的Http Server 使用Libevent内置的http相关接口,可以很容易的构建一个Http Server,一个简单的Http Server如下: #include <event2/e ...

  2. 3D场景定位的一些资源

    利用多张影像对小物体进行拍摄,进而进行三维重建,是计算机视觉中的重要问题之一. 目前对此研究最全面的网站是:http://vision.middlebury.edu/mview/eval/ 目前最优秀 ...

  3. 转--脉络清晰的BP神经网络讲解,赞

    http://www.cnblogs.com/wengzilin/archive/2013/04/24/3041019.html 学 习是神经网络一种最重要也最令人注目的特点.在神经网络的发展进程中, ...

  4. webbench之使用(二)

    [root@lam7 ~]# webbench -helpwebbench [option]... URL -f|--force                Don't wait for reply ...

  5. bzoj3212 pku3468 A Simple Problem with Integers

    一个有初值的数列.区间加.区间查 用线段树直接水过 然而并没有1A,主要是做题太快没看规模结果没注意线段树要用longlong建 卧槽怎么可以这么坑爹,害得我看见wa心慌了,还以为连线段树都要跪 一开 ...

  6. angularJS学习资源最全汇总

    基础 官方: http://docs.angularjs.org angularjs官方网站已被墙,可看 http://www.ngnice.com/: 官方zip下载包 https://github ...

  7. ArrayList 实现删除重复元素(元素为对象类型)

    package 集合; import java.util.ArrayList;import java.util.Iterator; /* * 删除集合中的重复的元素(元素是对象形式的) *  * Li ...

  8. 【Leetcode】Longest Palindromic Substring

    问题:https://leetcode.com/problems/longest-palindromic-substring/ 给定一个字符串 S,求出 S 的最长回文子串 思路: 1. 回文:一个字 ...

  9. *HDU2852 树状数组(求第K小的数)

    KiKi's K-Number Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  10. *HDU1053 哈夫曼编码

    Entropy Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Sub ...