4

I want to update a UserField client side. I found the following code at this topic How to Use ECMA CSOM to Set a Field of Type SPFieldUserValue

Tried the following code:

var users = new Array(); users.push(SP.FieldUserValue.fromUser("testAias1")); users.push(SP.FieldUserValue.fromUser("testAias2")); item.set_item(columnName, users); item.update(); 

I'm getting the following error:

"Invalid look-up value. A look-up field contains invalid data. Please check the value and try again."

It's not working if I want to add an array of users to a field. It only works for one user ex:

item.set_item(columnName, SP.FieldUserValue.fromUser("testAias1")); 

Any ideas why?

3 Answers 3

4

Ok, so I finally figured it out. This is what worked for me:

var users = User1_ID + ';#' + User1_Name + ';#' + User2_ID + ';#' + User2_Name; listItem.set_item(fieldName, users); listItem.update(); 
1
  • Hi, I have used client side people picker, and I have same problem as you have, how do I get User_id and User_name from a people picker Entity? thank you for your help. Commented Mar 8, 2013 at 15:35
-1

Building on the answer from i_borgos this also works without the Display Name if that is unavailable.

var users = User1_ID + ';#;#' + User2_ID; listItem.set_item(fieldName, users); listItem.update(); 
-5

get all fields and just split with the help of JQuery

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.