I am using jQuery to query a Sharepoint 2013 list and expanding the AssignedTo field in order to get the user id. I was able to get the code working when the AssignedTo field only allowed one person, but when I changed it to allow multiple persons the code failed. This is the url I used for the single user but I don't have any idea of how I need to change this to get multiple assigned to users.
http://ift.tt/1GeqqAu('DEBUG - PLOT Compliance Exceptions')/items?$select=Id,AssignedTo/Title,Title,Comment,Exception_x0020_Type&$expand=AssignedTo/Title&$filter=(Status ne 'Closed' and Status ne 'Closed By System')&$top=5000
I would be OK with getting a string with all the user names if that is the only possibility. Once I get a valid url then I would need to step through the data. This is the code I am using to display the data in a jQuery datatable, so I'll have to know how the data is structured in order to be able to dig down and get all the user names.
var call = $.ajax({
async: false,
url: _spPageContextInfo.webAbsoluteUrl
+ "/_api/Web/Lists/GetByTitle('DEBUG - PLOT Compliance Exceptions')/items"
+ "?$select=Id,AssignedTo/Title,Title,Comment,Exception_x0020_Type"
+ "&$expand=AssignedTo/Title"
+ "&$filter=(Status ne 'Closed' and Status ne 'Closed By System')"
+ "&$top=5000",
type: "GET",
dataType: "json",
headers: {
Accept: "application/json;odata=verbose"
}
});
call.done(function(data, textStatus, jqXHR) {
$('#issuesDataTable').dataTable({
"bLengthChange": false,
"bDestroy": true,
"bProcessing": true,
"aaData": data.d.results,
"aoColumns": [
{
"mData": "Id",
"fnRender": function(obj) {
var href = _spPageContextInfo.webAbsoluteUrl
+ '/Lists/DEBUG PLOT Compliance Exception List/EditForm.aspx?IsDlg=1&ID='
+ obj.aData.Id;
//return '<a href="' + href + '">' + obj.aData.Id + '</a>';
return '<a href="#" onclick="openInDialog(0,0,true,true,true,\'' + href + '\');">' + obj.aData.Id + '</a>';
}
},
{
"mData": "AssignedTo",
"fnRender": function(obj) {
if(obj.aData.AssignedTo.Title) {
var str = obj.aData.AssignedTo.Title.toString();
return str;
} else {
return "NA";
}
}
},
{"mData": "Title"},
{"mData": "Comment"},
{"mData": "Exception_x0020_Type"}
]
});
});
call.fail(function(jqXHR, textStatus, errorThrown) {
alert("Error retrieving Tasks: " + jqXHR.responseText);
});
Thanks

0 commentaires:
Enregistrer un commentaire