[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项目记]-DB脚本同步
BI项目中会有很多不同种类的项目,其中比较比较大的一部分就是对DB脚本的处理.然而DB的脚本毕竟无法在项目中进行维护,所以这里介绍如何对DB的脚本进行版本上的维护. 数据库脚本本身没有项目模板支持,很 ...
- Jetty使用教程(四:28-30)—Jetty开发指南
二十八.延续机制支持 28.1 延续简介 延续是一种机制用来实现类似于Servlet 3.0异步功能的异步Servlet,但提供了一个简单易操作的接口. 28.1.1 为什么使用异步Servlets ...
- 图像缩放_OpenCv
图像缩放是一种比较简单的图像处理操作,这里给出opencv中的代码, opencv的版本C语言接口 int resize_c() { const char *pstrImageName = " ...
- WEB容器启动——web.xml加载详解
最近在看spring的源码,关于web.xml文件在容器(Tomcat.JBOSS等)启动时加载顺序问题很混乱,通过搜集资料,得出以下的结论: 1.加载顺序与它们在 web.xml 文件中的先后顺序无 ...
- 2016 Multi-University Training Contest 3
5/11 2016 Multi-University Training Contest 3官方题解 2016年多校训练第三场 老年选手历险记 暴力 A Sqrt Bo(CYD) 题意:问进行多少次开根 ...
- Leetcode 3Sum Closest
Given an array S of n integers, find three integers in S such that the sum is closest to a given num ...
- cetnos 7 ntp服务的安装与配置
首先需要搭建yum本地仓库 http://www.cnblogs.com/jw35/p/5967677.html #搭建yum仓库方法 yum install ntp -y #安装n ...
- mysql在线修改表结构大数据表的风险与解决办法归纳
整理这篇文章的缘由: 互联网应用会频繁加功能,修改需求.那么表结构也会经常修改,加字段,加索引.在线直接在生产环境的表中修改表结构,对用户使用网站是有影响. 以前我一直为这个问题头痛.当然那个时候不需 ...
- Linux查看进程PID信息
ps -ef|grep 进程名 可检索到具体进程PID以及启动命令行信息 ls -l /proc/进程ID Linux在启动程序时会在 /proc/PID 目录下以PID为名称创建一个文件存储相关进程 ...
- easyUI 表格
1.创建 <table id ="ID"></table> 2.属性 dategrid: columns 列的定义的数组 URl:访问远程数据的数组 [“t ...