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. PHP获取当前url路径的函数及服务器变量:QUERY_STRING、REQUEST_URI、SCRIPT...

    1,$_SERVER["QUERY_STRING"]说明:查询(query)的字符串 2,$_SERVER["REQUEST_URI"]说明:访问此页面所需的U ...

  2. RISC指令集的五个周期

    RISC指令集的五个周期 RISC(reduced instruction set computer,精简指令集计算机)简称为精简指令集.RISC把执行指令的精力主要放在了经常使用的指令上面.本文主要 ...

  3. xamarin.Android 标记1

    群里一个朋友的博客 推荐一下 自己也做个书签记录. http://sunyt.me/2015/04/15/Xamarin-FAQ/

  4. Deep Learning模型之:CNN卷积神经网络(一)深度解析CNN

    http://m.blog.csdn.net/blog/wu010555688/24487301 本文整理了网上几位大牛的博客,详细地讲解了CNN的基础结构与核心思想,欢迎交流. [1]Deep le ...

  5. python excel操作

    python操作excel表格(xlrd/xlwt)转载:http://www.cnblogs.com/zhoujie/p/python18.html   最近遇到一个情景,就是定期生成并发送服务器使 ...

  6. Page-encoding specified in XML prolog (UTF-8) is different from that specified in page directive (utf-8)

    org.apache.jasper.JasperException:xxx.jsp(1,1) Page-encoding specified in XML prolog (UTF-8) is diff ...

  7. CodeForces462 A. Appleman and Easy Task

    A. Appleman and Easy Task time limit per test 1 second memory limit per test 256 megabytes input sta ...

  8. Codeforces Round #107 (Div. 2)

    D题 并查集+组合 #include <iostream> #include <cstdio> #include <cstring> using namespace ...

  9. Android -- 启动另外一个Activity的方式(2s自动启动)

    1.  使用Handler  并且可以设置进入和退出的动画效果 Class < ? > activityClass; Class [ ] paramTypes = { Integer.TY ...

  10. Repeater用法

    Repeater用法: 使用Repeater可以绘制表头.表内.表尾比较复杂的表格,如以下实例: <asp:Repeater ID="Repeater1" runat=&qu ...