I have a small requirement regarding People Picker Data.
What i am trying to do in the below code is to fetch data from List A into List B. There are various columns involved but the one i am facing problem with is People Picker.
I am able to fetch People-Picker Value with no issues but it only gives me 100 values in the array and the problem with that is there are duplicate values.
Thus, As the 100 items do involve names but there are few names which are missed due to the duplication.
When i am appending the Names into the dropwdown, i am removing the duplicate values but i am not able to get all the names in that column.
//To get all employees name.
function getAllEmployeeNames(){
var results;
$.ajax({
url: _spPageContextInfo.siteAbsoluteUrl + "/_api/web/lists/getbytitle('Should Cost Projects')/items?$select=Should_x0020_Cost_x0020_Modeler/Title&$expand=Should_x0020_Cost_x0020_Modeler/Id",
type: "GET",
async:false,
headers: {
"Accept": "application/json;odata=verbose",
},
success: function (data) {
if(data.d.results.length>0){
results=data.d.results;
}
},
error: function (data) {
//alert("Error");
}
});
return results;
console.log(results);
}
// To append employee name into dropdown.
var employeeName=$("input[title^='Employee Name']").val();
$("input[title^='Employee Name']").hide();
$("input[title^='Employee Name']").after("<select id='EmployeeField' class='ms-RadioText'><option value=''></option></select>");
var allEmployeeNames=getAllEmployeeNames();
$.each(allEmployeeNames,function(i,employee){
$.each(employee.Should_x0020_Cost_x0020_Modeler.results,function(j,item){
console.log(employee.Should_x0020_Cost_x0020_Modeler.results);
// if(employeeName==item.Title){
$("#EmployeeField").append("<option selected='selected' value='"+item.Title+"'>"+item.Title+"</option>");
/*}else{
if(item.Title!=undefined){
$("#EmployeeField").append("<option value='"+item.Title+"'>"+item.Title+"</option>");
console.log("undefined");
}
} */
});
});
//To remove duplicate values after appending into dropdown
$("#EmployeeField option").each(function() {
$(this).siblings('[value="'+ $(this).val() +'"]').remove();
});
Specific Requirement: I want to get all the people-picker names not only 100 names from List A.
Would really appreciate if you could help me on this.