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

I'm trying to update a list item with the SharePoint 2010 Client Object Model and Javascript.The

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);

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);
Share Improve this question asked Aug 12, 2011 at 16:30 TomTom 1301 silver badge5 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3
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./2011/10/adding-new-document-item-whose-metadata.html

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745484507a4629704.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信