I'm updating a multiple value lookup field via REST with the following code:
var itemProperties = {
'__metadata': { "type": "SP.Data.QuestionsListItem" },
'AnsChoicesId': { "results": [1,3] } // multi-valued field
};
$.ajax({
url: appweburl + "/_api/web/lists/GetByTitle('Questions')/items("+ListItem+")",
type: "MERGE",
data: JSON.stringify(itemProperties),
headers: {
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"accept": "application/json; odata=verbose",
"If-Match": "*",
"content-type": "application/json;odata=verbose"
}
}).done(function () {
console.log("Done");
}).fail(function () {
console.log("FaiL");
});
This works fine. However, it's replacing every value in the multiple value lookup field. Is it possible to use a .pop()
and/or .push()
technique instead of replacing all the array items?