1
如果我選擇一個資源名稱(人員選擇器列),那麼剩餘的EmpID 項目和經理列必須填寫。所有這些列都在名爲「EmpDetails」的列表中。 我嘗試使用CAML查詢,但無法成功。這是我的代碼:從Sharepoint 2013中的其他列表中獲取Peoplepicker字段的詳細信息
<tr class="container">
<div id="container">
<table id="table">
<thead>
<tr>
<th>Resource Name</th>
<th>EmpID</th>
<th>Projects</th>
<th>Manager</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td><span id="resourcename"></span></td>
<td><input type="text" id="txtempid" placeholder="Emp ID"/></td>
<td><input type="text" id="txtprojects" placeholder="Projects"/></td>
<td><input type="text" id="txtreportmgr" placeholder="Reporting Manager"/></td>
<td><input type="button" id="delrow" value="-" onclick="deleteRow(this)"/> </td>
<td><input type="button" id="addrow" value="+" onclick="addRow()"/> </td>
</tr>
</tbody>
</table>
</div>
</tr>
Javascript代碼:
$(document).ready(function() {
ConvertoToRequestPeoplePicker('resourcename');
BindData();
});
function BindData()
{
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function() {
context = new SP.ClientContext.get_current();
LoadingMessage();
SPLoaded();
});
}
function SPLoaded()
{
try
{
var resourceInfoList = context.get_web().get_lists().getByTitle('EmpDetails');
var resourceInfoQuery = new SP.CamlQuery();
resourceInfoQuery.set_viewXml( '<View>' +
'<ViewFields>' +
'<FieldRef Name=\'EmpID\' />' +
'<FieldRef Name=\'Projects\' />' +
'<FieldRef Name=\'Manager\' />' +
'</ViewFields>' +
'<Query>' +
'<Where>' +
'<Value Type="User">' + itm.get_item("Employee").get_lookupId() + '</Value>'+
'</Where>' +
'<OrderBy>' +
'<FieldRef Name="Title" Ascending="TRUE" />' +
'</OrderBy>' +
'</Query>' +
'</View>');
var resourceInfoListItems = resourceInfoList.getItems(resourceInfoQuery);
context.load(resourceInfoListItems);
context.executeQueryAsync(Function.createDelegate(null, LoadConfigurationValues), Function.createDelegate(this, function (sender, arg) { alert("Error in getLoginUser : " + arg.get_message()); waitDialogLoad.close(SP.UI.DialogResult.OK); }));
}
catch(ex)
{
alert("Something went wrong : "+ex.message);
waitDialogLoad.close(SP.UI.DialogResult.OK);
}
}
我在SharePoint初學者和有一些網站上面的代碼。我不知道這是否是正確的代碼或否。請幫忙。