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. 【Java EE 学习 34】【struts2学习第一天】

    一.struts2简介 struts2是一个用来开发MVC应用程序的框架.它提供了Web应用程序开发过程中的一些常见问题的解决方案. 1.struts2的作用域范围:三层架构当中的第一层,相当于MVC ...

  2. 1.oracle 12c基础

    1.查看数据库的创建模式 SQL> select name,cdb,con_id from v$database; NAME      CDB     CON_ID ---------    - ...

  3. 事务操作(BEGIN/COMMIT/ROLLBACK/SAVE TRANSACTION)

    BEGIN TRANSACTION 标记一个显式本地事务的起始点. BEGIN TRANSACTION 使 @@TRANCOUNT 按 1 递增. BEGIN TRANSACTION 代表一点,由连接 ...

  4. linux apt-get install 错误: Package has no installation candidate

    sudo apt-get install vim 在安装vim时报如下错误: Error accoured: This may mean that the package is missing, ha ...

  5. 激活Windows 8.1 RTM原来如此简单

    日前,Windows 8.1 RTM各种版本已经在坊间泄露开来,许多迫不及待的用户也开始跃跃欲试,但可能有人会疑惑,Windows 8.1RTM该如何激活?其实,它远比你想象的要简单. 实际上,Win ...

  6. ios8 设置单元格分割线无效

    原来: [self.tableView setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 0)];//分隔线紧贴左右边框 || [self.tableView s ...

  7. NOIP2009多项式输出(水)【A004】

    [A004]潜伏者[难度A]—————————————————————————————————————————————————————————————————————————— [题目要求] 一元 n ...

  8. 云虚拟主机开源 DedeCMS 安装指南

    1. 获取主机 FTP 和 数据库 信息 1.1 FTP 信息 登录主机管理后台,在 站点信息 中获取到 FTP 和 数据库 的账号密码,连接地址. 如下图所示: 如果忘记密码,可以在这里进行 重置密 ...

  9. Win7下完全卸载Oracle 11g

    1 右击“计算机”-->管理-->服务和应用程序-->服务,停掉所有Oracle相关的服务(以Oracle打头的,比如OracleDBConsoleorcl). 2 开始--> ...

  10. blur和click事件的先后顺序问题

    这两个同时用会有冲突.懒得翻译了,需要的自己看哈. 以下摘自stackoverflow. I have an input field, where I try to make autocomplete ...