如何使用jsom在列表中存储查找值 [英] How to store lookup values in list using jsom
问题描述
大家好,
我有一个共享点列表,它有一些查找和普通列,我想插入新记录,但代码下方不能正常工作。
var clientContext = new SP.ClientContext.get_current();
var oList = clientContext.get_web()。get_lists()。getByTitle('Batch');
var itemCreateInfo = new SP.ListItemCreationInformation();
这个。 oListItem = oList.addItem(itemCreateInfo);
/ * var DCCC = new SP.FieldLookupValue();
ICC.set_lookupId(dcCycleValue);
listItem。 set_item(" IC",dcCycleText); * /
var DCC = new SP.FieldLookupValue();
DCC.set_lookupId(dcTypeValue);
oListItem.set_item(" DCTypeLookup",dcTypeText);
$
var VCC = new SP.FieldLookupValue();
VCC.set_lookupId(venueValue);
oListItem.set_item("Venue",venueText);
var ICCC = new SP.FieldLookupValue();
VCC.set_lookupId (dcCycleValue);
oListItem.set_item(" DCID",dcCycleText);
var assignedToVal = new SP.FieldUserValue();
assignedToVal.set_lookupId(userName);
oListItem .set_item(" Facilitator",assignedToVal);
< span style ="white-space:pre">
oListItem.set_item('BatchSize',sizeofBatch);
oListItem.set_item('DCStartDate',startDateValue); //这是一个LOOKUP值
oListItem.set_item('DCEndDate',endDateValue);
oListItem.update();
clientContext.load(oListItem);
clientContext.executeQueryAsync(onQuerySucceeded,onQueryFailed);
函数onQuerySucceeded()
{
alert('Item created:'+ oListItem.get_id ());
}
函数onQueryFailed(sender,args)
{
alert('请求失败。 '+ args.get_message()+'\ n'+ args.get_stackTrace());
}
当我运行此代码时,我收到以下错误
以下是几个讨论了查找列的博客
https://social.technet.microsoft.com/wiki /contents/articles/38264.sharepoint-lookup-columns.aspx
https://sharepoint.stackexchange.com/questions/73252/sharepoint-client-model-and-setting-up -lookup-field
https://stackoverflow.com/questions/21209228/sharepoint-2013-javascript-insert-item-with-查找字段
Hello all,
I have one sharepoint list, which has some lookup and normal column, I want to insert new record but below code not work properly.
var clientContext = new SP.ClientContext.get_current();var oList = clientContext.get_web().get_lists().getByTitle('Batch');
var itemCreateInfo = new SP.ListItemCreationInformation();
this.oListItem = oList.addItem(itemCreateInfo);
/*var DCCC = new SP.FieldLookupValue();
ICC.set_lookupId(dcCycleValue);
listItem.set_item("IC", dcCycleText);*/
var DCC = new SP.FieldLookupValue();
DCC.set_lookupId(dcTypeValue);
oListItem.set_item("DCTypeLookup",dcTypeText);
var VCC = new SP.FieldLookupValue();
VCC.set_lookupId(venueValue);
oListItem.set_item("Venue", venueText);
var ICCC = new SP.FieldLookupValue();
VCC.set_lookupId(dcCycleValue);
oListItem.set_item("DCID",dcCycleText);
var assignedToVal = new SP.FieldUserValue();
assignedToVal.set_lookupId(userName);
oListItem .set_item("Facilitator",assignedToVal);
oListItem.set_item('BatchSize',sizeofBatch);
oListItem.set_item('DCStartDate',startDateValue); // THIS IS A LOOKUP VALUE
oListItem.set_item('DCEndDate',endDateValue);
oListItem.update();
clientContext.load(oListItem);
clientContext.executeQueryAsync(onQuerySucceeded,onQueryFailed);
function onQuerySucceeded()
{
alert('Item created: ' + oListItem.get_id());
}
function onQueryFailed(sender, args)
{
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
when i run this code i got below error
Here are the few blogs that talked about the look up column
https://social.technet.microsoft.com/wiki/contents/articles/38264.sharepoint-lookup-columns.aspx
https://sharepoint.stackexchange.com/questions/73252/sharepoint-client-model-and-setting-up-lookup-field
https://stackoverflow.com/questions/21209228/sharepoint-2013-javascript-insert-item-with-lookup-field
这篇关于如何使用jsom在列表中存储查找值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!