SharePoint 2010客户端对象模型+使用JavaScript设置多重查找字段的值 [英] SharePoint 2010 Client Object Model + set the value of a multiple lookup field with Javascript
本文介绍了SharePoint 2010客户端对象模型+使用JavaScript设置多重查找字段的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用SharePoint 2010客户端对象模型和Javascript更新列表项.我尝试更新的项目具有多值查找"字段.我可以成功设置此字段,但只能使用一个值.有人知道如何使用多个值进行设置吗?
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();
这篇关于SharePoint 2010客户端对象模型+使用JavaScript设置多重查找字段的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文