SharePoint 2010客户端对象模型+使用Javascript设置多个查找字段的值

时间:2011-08-12 16:30:27

标签: javascript sharepoint sharepoint-clientobject

我正在尝试使用SharePoint 2010客户端对象模型和Javascript更新列表项。我正在尝试更新的项目具有“多值查找”字段。我可以成功设置此字段,但只能使用一个值。有谁知道如何用多个值设置它?

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

2 个答案:

答案 0 :(得分: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();

答案 1 :(得分:1)

我创建了一篇博客文章,清楚地解释了如何添加包含查找字段元数据的列表项。

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