[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 ...
随机推荐
- python学习笔记(1)
python简介 python是Guido van Rossum在圣诞节打发无聊的时间时候写出来的语言. python是解释性的语言. python是动态类型的语言. python是强类型定义语言(高 ...
- 动态添加LinearLayout的高度
WindowManager wm = (WindowManager) getContext() .getSystemService(Context.WINDOW_SERVICE); int width ...
- Visual Studio 插件的开发(转)
起因 在做项目的时候,经常需要根据表结构create一些实体类,写多了,实在是觉得无趣,于是就琢磨着做个代码生成工具.当然现在有很多现成的,拿来用就好,可是总想自己弄个出来玩玩,一来是当初用DataS ...
- HDU5322 Hope(DP + CDQ分治 + NTT)
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5322 Description Hope is a good thing, which can ...
- 【转】java-String中的 intern()
转自:http://blog.sina.com.cn/s/blog_69dcd5ed0101171h.html 1. 首先String不属于8种基本数据类型,String是一个对象. 因为对象的默认值 ...
- 踩坑事件:windows操作系统下的eclipse中编写SparkSQL不能从本地读取或者保存parquet文件
这个大坑... .... 如题,在Windows的eclipse中编写SparkSQL代码时,编写如下代码时,一运行就抛出一堆空指针异常: // 首先还是创建SparkConf SparkConf c ...
- 如何将U盘内文件拷入VMware Linux CentOS6.5虚拟机
之前在Linux CentOS下安装Oracle这篇随笔中我提到要将下载到的安装文件解压缩 那么,问题来了! 如何把下载到的文件拷入虚拟机中呢? 我是这样做的: 1.将下载到的文件拷入U盘 2.以ro ...
- BZOJ1453: [Wc]Dface双面棋盘
Description Input Output Sample Input Sample Output HINT 线段树套并查集应该是比较好写的做法,时间复杂度为O(N^3+M*NlogN). #in ...
- HTML常用属性
blue:蓝色 red:红色 yellow:黄色 green:绿色 white:白色 gray:灰色 /*去掉下划线*/ text-decoration: none; /*添加下划线*/ te ...
- webform 简单控件
html中12个表单元素添加runat="server"后称为控件 Lable 编译之后是 <span></span> 属性:CssClass 编译成 c ...