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. Django【基础篇】

    Python的WEB框架有Django.Tornado.Flask 等多种,Django相较与其他WEB框架其优势为:大而全,框架本身集成了ORM.模型绑定.模板引擎.缓存.Session等诸多功能. ...

  2. 【Java EE 学习 46】【Hibernate学习第三天】【多对多关系映射】

    一.多对多关系概述 以学生和课程之间的关系为例. 1.在多对多关系中涉及到的表有三张,两张实体表,一张专门用于维护关系的表. 2.多对多关系中两个实体类中应当分别添加对方的Set集合的属性,并提供se ...

  3. Ajax验证用户名是否存在模板

    Jsp 页面 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8 ...

  4. 中间人攻击(MITM)姿势总结

    相关学习资料 http://www.cnblogs.com/LittleHann/p/3733469.html http://www.cnblogs.com/LittleHann/p/3738141. ...

  5. jquery取值

    1. 如何用jquery获取<input id="test" name="test" type="text"/>中输入的值?$( ...

  6. Git的简单使用教程

    Git是一款免费.开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目. GitHub则可以托管各种git库,并提供一个web界面,但与其它像 SourceForge或Google Code ...

  7. php5.6+apache2.4环境配置

    Apache2.4 环境:https://www.microsoft.com/en-US/download/details.aspx?id=48145php5.6 环境:http://www.micr ...

  8. *HDU1598 并查集

    find the most comfortable road Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ...

  9. vs2015帮助文档

    1)注释快捷键: CTRL + K - CTRL + C (注释) CTRL + K 然后 CTRL + U (取消注释) shift+"*"---------整段(取消)注释 2 ...

  10. Oracle ITL(Interested Transaction List)理解

    ITL(Interested Transaction List) ITL是位于数据块头部的事物槽列表,它是由一系列的ITS(Interested Transaction Slot,事物槽)组成,其初始 ...