SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a sharepoint list, with a lookupfield for users. The column name is "SystemUser". I have successfully added a listitem by using javascript, setting the "SystemUser" to the current user by calling web.get_currentUser();

I want to set another user to the field "Users". I get the users list (web.get_siteUserInfoList()), and retrieve the user with a given ID. When the user is loaded, I set the loaded user as a value to the field "SystemUser".

But this approach does not work. I get the following errormessage (translated):

"An error occured: Invalid data is used to update the listelement. The field you tried to update could be writeprotected. Undefined";

Any ideas? Here's the code:

function () {
window.dialog = $(this);
var context = SP.ClientContext.get_current();
var web = context.get_web();
var list = web.get_lists().getByTitle('MyList');
var listItemCreationInformation = new SP.ListItemCreationInformation();
var listItem = list.addItem(listItemCreationInformation);

var name = $('#<%=txtbxName.ClientID %>').val();
var selectedUserID = $('#<%=hiddenUserFieldID.ClientID %>').val();

var userList = web.get_siteUserInfoList();
var selectedUser = userList.getItemById(selectedUserID);

context.executeQueryAsync(function () {
    listItem.set_item('SystemUser', selectedUser);

    context.executeQueryAsync(function () {
        function (sender, args) {
            alert('Inner exception: ' + args.get_message() + '\n' + args.get_stackTrace());

        }, function (sender, args) {
            alert('Outer exception: ' + args.get_message() + '\n' + args.get_stackTrace());
share|improve this question
up vote 0 down vote accepted

Instead of writing the selectedUser (which I think is an SPUser object?) you should write a SPUserLookupValue, or it's string equivalent which is ID;#Name, i.e. 1;#David Lozzi.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.