1. 向 executeQueryAsync 中传递参数可以使用以下两种方式,也可以参考这篇文章

var mySuccessCallBack = Function.createCallback(onQuerySucceeded, oListItem);
clientContext.executeQueryAsync(Function.createDelegate(this, mySuccessCallBack),Function.createDelegate(this, onQueryFailed));
function onQuerySucceeded(sender, args, item){
alert("Added"+ item.get_id());
} function onQueryFailed(sender, args){
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

或者:

clientContext.executeQueryAsync(Function.createDelegate(this, function(){onQuerySucceeded(oListItem);}), Function.createDelegate(this, onQueryFailed));
function onQuerySucceeded(item){
alert("Added"+ item.get_id());
}
function onQueryFailed(sender, args){
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

2. 下面代码演示了SharePoint 2013 中如何使用 client-side people picker control 并获取用户信息,参考链接

引用内置JS文件:(注意,在content edit webpart 中最好不要使用 <SharePoint:ScriptLink name="clienttemplates.js" runat="server" LoadAfterUI="true" Localizable="false" /> 来引用内置文件,因为<SharePoint:ScriptLink>需要包含在<asp:Content>标签内,在Content Edit Webpart内使用时,可能不起作用)

<script type="text/javascript" src="/_layouts/15/clienttemplates.js"></script>
<script type="text/javascript" src="/_layouts/15/clientforms.js"></script>
<script type="text/javascript" src="/_layouts/15/autofill.js"></script>
<script type="text/javascript" src="/_layouts/15/clientpeoplepicker.js"></script>

JavaScript:

<script type="text/javascript" src="/angularJS/SiteAssets/Scripts/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
// Run your custom code when the DOM is ready.
$(document).ready(function () {
// Specify the unique ID of the DOM element where the
// picker will render.
initializePeoplePicker('peoplePickerDiv');
}); // Render and initialize the client-side People Picker.
function initializePeoplePicker(peoplePickerElementId) {
// Create a schema to store picker properties, and set the properties.
var schema = {};
schema['PrincipalAccountType'] = 'User,DL,SecGroup,SPGroup';
schema['SearchPrincipalSource'] = 15;
schema['ResolvePrincipalSource'] = 15;
schema['AllowMultipleValues'] = true;
schema['MaximumEntitySuggestions'] = 50;
schema['Width'] = '280px'; // Render and initialize the picker.
// Pass the ID of the DOM element that contains the picker, an array of initial
// PickerEntity objects to set the picker value, and a schema that defines
// picker properties.
this.SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementId, null, schema);
} // Query the picker for user information.
function getUserInfo() {
// Get the people picker object from the page.
var peoplePicker = this.SPClientPeoplePicker.SPClientPeoplePickerDict.peoplePickerDiv_TopSpan; // Get information about all users.
var users = peoplePicker.GetAllUserInfo();
var userInfo = '';
for (var i = 0; i < users.length; i++) {
var user = users[i];
for (var userProperty in user) {
userInfo += userProperty + ': ' + user[userProperty] + '<br>';
}
}
$('#resolvedUsers').html(userInfo); // Get user keys.
var keys = peoplePicker.GetAllUserKeys();
$('#userKeys').html(keys); // Get the first user's ID by using the login name.
getUserId(users[0].Key);
} // Get the user ID.
function getUserId(loginName) {
var context = new SP.ClientContext.get_current();
this.user = context.get_web().ensureUser(loginName);
context.load(this.user);
context.executeQueryAsync(
Function.createDelegate(null, ensureUserSuccess),
Function.createDelegate(null, onFail)
);
} function ensureUserSuccess() {
$('#userId').html(this.user.get_id());
} function onFail(sender, args) {
alert('Query failed. Error: ' + args.get_message());
}
</script>

HTML:

<div id="peoplePickerDiv"></div>
<div>
<br/>
<input type="button" value="Get User Info" onclick="getUserInfo()"></input>
<br/>
<h1>User info:</h1>
<p id="resolvedUsers"></p>
<h1>User keys:</h1>
<p id="userKeys"></p>
<h1>User ID:</h1>
<p id="userId"></p>
</div>

3.

SharePoint 2013 - Client OM的更多相关文章

  1. SharePoint 2013 - Client Side Rendering

    1. Client side rendering 代码结构为: (function () { // Create object that have the context information ab ...

  2. SharePoint 2013 版本功能对比

    前言:在SharePoint使用中,经常纠结于版本问题,SharePoint 2013主要有免费的Foundation和收费的标准版.企业版三个版本,他们之间的功能上是不一样的,找了一些资料才发现下面 ...

  3. SharePoint 2013版本功能对比介绍

    转:http://www.fengfly.com/plus/view-213720-1.html 在SharePoint使用中,经常纠结于版本问题,SharePoint 2013主要有免费的Found ...

  4. Integrating SharePoint 2013 with ADFS and Shibboleth

    Time again to attempt to implement that exciting technology, Federation Services (Web Single Sign On ...

  5. SharePoint 2013 Excel Services ECMAScript 示例之明日限行

    前言:最近遇到一个“明日限行”的功能,北京的交通啊,这个不在今天讨论范围内,暂不吐槽,想想代码开发,还要写WebPart部署,很麻烦,而且部署服务器,需要领导审批,想绕过这个麻烦事儿,就想到客户端了, ...

  6. SharePoint 2013技巧分享系列 - 同步Exchange显示高清用户照片

    在“SharePoint 2013技巧分享系列 - Active Directory同步显示用户照片”文中介绍了如何同步Active Directory显示用户照片,但是同步完成后,用户照片尺寸和清晰 ...

  7. SharePoint 2013常用开发工具分享

    众所周知,一款好的开发工具不仅能提高项目开发效率,而且能够协助开发人员简化开发流程.本文汇总几款SharePoint 2013开发常用开发工具,希望能够对大家有所帮助.如果您有更好的工具,没有包含在本 ...

  8. 在Windows Server 2012 R2上安装SharePoint 2013 with SP1失败,提示没有.net4.5的解决办法

    现在的Server用Windows Server 2012 R2的越来越多了,在部署带Sp1的SharePoint2013的时候,走完预安装工具后,点击setup提示缺少.net4.5. 其实Wind ...

  9. SharePoint 2013 中的 PowerPoint Automation Services

    简介                许多大型和小型企业都将其 Microsoft SharePoint Server 库用作 Microsoft PowerPoint 演示文稿的存储库.所有这些企业在 ...

随机推荐

  1. TX2 默认root用户启动

    Jetpack3.1 修改方式 修改1 gedit /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf 修改后: 修改2 gedit /root/.pro ...

  2. 在文件夹快速启动cmd或powershell

    进入指定目录下的几种方法:一般方法 使用win+R的组合键进入运行窗口运行窗口输入cmd进入命令行,使用 ”cd 文件路径“进入指定的文件夹下.cd 命令的基本操作如下: 任意目录下跳转至当前驱动器的 ...

  3. Python循环流程

    1.for循环 计算1+2+3+……+100的和 count = 0 i = 1 for i in range(101): count+=i print(count) 前n项和公式为:Sn=n*a1+ ...

  4. python学习之路---day06

    一:is 和 == 的区别 01)a b 两个变量 is 是比较变量的内存地址,如果地址相等,则返回True,如果不相等,则返回False == 是比较变量两边内容是否一样,如果一样则返回True,不 ...

  5. JSTL的核心标签

    JSTL的核心标签: .if: 语法:<c:if test="" var="" scope=""></c:if> 当 ...

  6. 关于vue2非表单元素使用contenteditable="true"实现textarea高度自适应

    <template> <div ref="sendContent" contenteditable="true" v-html="s ...

  7. 关闭PhpStorm拼写错误

  8. fis中的数据结构模块Config

    /* * config * caoke */ 'use strict'; Object.extend=function(props){ //继承父类 var prototype=Object.crea ...

  9. vim(三)golang代码跳转配

    在golang的代码里跳来跳去.... godef 安装 跳转是通过godef实现,godef的安装目录一般是$GOBIN,只要让godef命令在$PATH下即可 godef 命令安装: go get ...

  10. mysql 学习之 DDl语句

    mysql 1,登入mysq1: mysql -uroot -p  ---->密码隐藏登入好点 2,mysql操作: 创建数据库:create databases test1; 查看数据库:sh ...