我正在使用 SPServices(GetListItems 方法)从共享点列表中获取一些信息。该列表包含一个“人员或组”类型字段,该字段返回用户的数字 ID 和名称(显示名称),以分号分隔,例如“43#;John Doe”。我需要该字段中所有用户的电子邮件地址(在所有返回的行中)。任何人都可以帮忙吗?提前致谢。
问问题
8015 次
2 回答
4
保罗你摇滚:)
从保罗的最后评论中,我得到了所需的东西。这是完美的。:)
您唯一需要的是将以下内容添加到调用中
CAMLQueryOptions: "<QueryOptions><ExpandUserField>True</ExpandUserField></QueryOptions>",
所以我的示例调用变成了这个
$().SPServices({ operation: "GetListItems", async: false, listName: "Assignees", webURL: "https://col.wow.telenor.com/sites/go/",
CAMLViewFields: "<ViewFields Properties='True'/>",
CAMLQuery: "",
CAMLQueryOptions: "<QueryOptions><ExpandUserField>True</ExpandUserField></QueryOptions>",
completefunc: function (xData,Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function () {
try {
//ows_Name1 is a field of type "People or Group" the after adding CAMLQueryOptions this field returns all the fields
// propeties of user i.e. Displayname,ID,email id, domain login, sip ID etc all separate by #
var title = $(this).attr("ows_Name1");
// Splitting the resultant string with # give you string array of all the properties. In my case email ID is at
// index 3.
var userEmail = userText.split('#')[3];
// Below line is added to remove the trailing "," from email id
userEmail = userEmail.substring(0,userEmail.indexOf(','));
}
catch (e) {
alert('Exception: ' + e.message);
}
});
}
});
对不起,保罗,我必须取消标记你的答案并做出这个答案:)
于 2012-11-20T16:07:59.577 回答
1
@Mujaba,
我之前通过获取用户名并使用 People 服务和 SearchPrincipals 方法进行搜索来完成此操作...这是一个示例:
var userEmail = '';
var userId = '43';
$().SPServices({
operation: "SearchPrincipals",
searchText: "John Doe",
async: true,
completefunc: function(xData, status){
$(xData.responseXML).find("PrincipalInfo")
.each(function(){
var thisUser = $(this);
if ($.trim(thisUser.find("UserInfoID").text()) == userId) {
userEmail = $.trim(thisUser.find("Email").text());
alert("User's email: " + userEmail);
return false;
}
});
}
});
保罗。
于 2012-11-14T18:19:02.100 回答