3

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?

0

No,

because (deep down) in the SQL database it is one text-field NOT an Array.

REST, JSOM, CSOM, Powershell all write one value to this text-field.

There is no logic in between that handles pop/push

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.