I have a newrequest.aspx page in a Sharepoint 2013 App with a form on it to get details from my users to submit a leave request,this is then submitted to a Sharepoint list to hold all of the requests for a workflow. On this form I have created a peoplepicker using the following code:
<script type="text/javascript"> $(document).ready(function () { $("#manager").spPeoplePicker(); }); </script>
Then in my .js file I have the following code to retrieve the values from that peoplepicker :
var managerTitle = $("#manager_TopSpan_ResolvedList").find("span.ms-entity-resolved").attr("title");
Then I have the following code in the same .js file to submit these values to my list using javascript/ecmascript.(Note, I am only copying relevant code here, This all is part of a leave request app that I am busy with,so there is more fields in use but they all work fine)
Code:
var oList = context.get_web().get_lists().getByTitle("Leave Requests"); var itemCreateInfo = new SP.ListItemCreationInformation(); this.oListItem = oList.addItem(itemCreateInfo); oListItem.set_item("Manager", managerTitle); oListItem.update(); context.load(oListItem); context.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
The manager field chosen above is also a peoplepicker. I am looking for assistance to set that value. The code above gives an error by saying
Invalid data was used to update the field or the field may be read-only
I have googled and tried a lot of different recommendations to no avail. Any assistance will be appreciated.