Can't get the syntax right to update a SharePoint multiperson column.

some variables:

iArray // = array of multiple user ids
sArray = iArray.join(); // string of multiple user ids
json1 = "{'results': [" + iArray + "]}";
json2 = "{'results': [" + sArray + "]}";

hardcoding ids works:

data: JSON.stringify({
'From_x0020_ContactsId': {'results': [9,25]},
'__metadata': { 'type': 'SP.Data.Lib_x005f_RFI2Item' }

trying to pass an array or string, doesn't work:

'From_x0020_ContactsId': json1,
'From_x0020_ContactsId': json2,
'From_x0020_ContactsId': {'results': ["" + iArray + ""]},
'From_x0020_ContactsId': {'results': ["" + sArray + ""]},
'From_x0020_ContactsId': "{'results': [" + fIdArray.join() + "]}",
'From_x0020_ContactsId': {'__metadata': { 'type': 'Collection(Edm.Int32' }, 'results': iArray},

always primitive or Edm32 error. Suggestions?


As always, after struggling for hours on an issue then posting to StackExchange, I figure out the answer minutes later. I should have just passed the array as below, works for updating single or multiple users in this field:

'From_x0020_ContactsId': {'results': iArray},

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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