开发者

SharePoint 2010 Client Object Model + set the value of a multiple lookup field with Javascript

开发者 https://www.devze.com 2023-03-28 06:07 出处:网络
I\'m trying to update a list item with the SharePoint 2010 Client Object Model and Javascript.The item I am trying to update has a Multiple Value Lookup field.I can successfully set this field, but on

I'm trying to update a list item with the SharePoint 2010 Client Object Model and Javascript. The item I am trying to update has a Multiple Value Lookup field. I can successfully set this field, but only with one value. Does anyone know how to set it with multiple values?

var _newLookupField = new SP.FieldLookupValue();
    _newLookupField.set_lookupId(itemArray.toString()); //this works if array is only开发者_运维问答 1 item        

    currentItem.set_item('Lookup_x0020_Field', _newLookupField);


var lookupsIds = [1,2,4];
var lookups = [];
for (var ii in lookupsIds) {
    var lookupValue = new SP.FieldLookupValue();
    lookupValue.set_lookupId(lookupsIds[ii]);
    lookups.push(lookupValue);
}
currentItem.set_item('Lookup_x0020_Field', lookups);
currentItem.update();


I have created a blog post that clearly explain how to add a list item that contains metadata with lookup fields.

http://vangalvenkat.blogspot.com/2011/10/adding-new-document-item-whose-metadata.html

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号