Adding Multiple value to lookup field via REST

             var itemProperties = {
                ‘__metadata’: { “type”: “SP.Data.QuestionsListItem” },
                ‘AnsChoicesId’: { “results”: [1,3] }  //multi-valued User field value 
            };

            $.ajax({

                url: appweburl + “/_api/web/lists/GetByTitle(‘ListTitleGoesHere’)/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”);
            });


In the above code all of the array items will be replaced with the item ID’s specified. 

//code coming soon

Here is what adding Multiple values looks like in JSOM (This example is create a new record, not updating a record)

var clientContext = SP.ClientContext.get_current();
            var oList = clientContext.get_web().get_lists().getByTitle(‘ListTitleGoesHere’);
            var itemCreateInfo = new SP.ListItemCreationInformation();
            oListItem = oList.addItem(itemCreateInfo);
            oListItem.set_item(‘Title’, ‘HelloThisStuffWorld’);
            var lookupsIds = [1, 2, 3];
            var lookups = [];
            for (var ii in lookupsIds) {
                var lookupValue = new SP.FieldLookupValue();
                lookupValue.set_lookupId(lookupsIds[ii]);
                lookups.push(lookupValue);
            }
            oListItem.set_item(‘AnsChoices’, lookups);
            oListItem.update();
            clientContext.load(oListItem);
            clientContext.executeQueryAsync(
         function () { alert(“Success!”) },
         function () { alert(“Request failed”) }

        );

How do I populate a “Lookup” field via Elements.xml?

The schema.xml will look like:

  <Field Name=”Achievements” ID=”{3e69c1-b538-497b-a7f6-8b4388b8e}” DisplayName=”Achievements” Type=”Lookup” Format=”Dropdown” List=”Lists/Achieve_List” ShowField=”Achieve” >

The elements.xml will look like:

<Field Name=”Achievements”>1</Field>

OR (or if it’s a multiple value lookup field it will look like)

<Field Name=”Achievements”>1;#;#2;#;#3</Field>