javascript - 如何从 Sharepoint Online 中的查找列中检索文本?
问题描述
下面的代码有效,我终于从一个简单的列表中检索数据,问题是当我获得查找列时,它显示的是对象而不是值。
var ProductInfo = '';
var listItemEnum = collListItem.getEnumerator();
var section = oListItem.get_item("Section");
while (listItemEnum.moveNext()) {
if (oListItem.get_item('Section') === 'Πειραιως Leasing'){
}
var oListItem = listItemEnum.get_current();
ProductInfo += '\n\nID: '+ oListItem.get_id() +
'<\nTitle: ' + oListItem.get_item('Title') +
'\nLink: ' + oListItem.get_item('Link') +
'<\nSection>' + oListItem.get_item('Section').get_lookupValue();
}
var value = SP.FieldLookup.get_lookupField ('Section');
console.log(value);
alert(ProductInfo.toString());
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
</script><input type="button" value="Get Section" onclick="getSection()"/>```
解决方案
由于您已经设置了 var section = oListItem.get_item("Section") 再次使用该变量。这应该是您正在寻找的。
var ProductInfo = '';
var listItemEnum = collListItem.getEnumerator();
while (listItemEnum.moveNext()) {
if (oListItem.get_item('Section') === 'Πειραιως Leasing'){
}
var oListItem = listItemEnum.get_current();
var section = oListItem.get_item("Section");
ProductInfo += '\n\nID: '+ oListItem.get_id() +
'<\nTitle: ' + oListItem.get_item('Title') +
'\nLink: ' + oListItem.get_item('Link') +
'<\nSection>' + section.get_lookupValue();
}
console.log(section.get_lookupId());
console.log(section.get_lookupValue());
alert(ProductInfo.toString());
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
推荐阅读
- javascript - ReactJS:在特定组件中包含脚本
- javascript - Kafka消费者onmessage - api调用对每条消息进行多次调用?
- java - (谓词)或(字符串)
- vue.js - Vue改变图标点击按钮
- python - BeautifulSoup 从变量中提取 json 作为没有 TAG 的字符串
- dart - 如何在 Flutter 中创建多个 DropdownButton?
- mysql - 试图在 mysql 中编辑 my.cnf 文件,但它不起作用
- firebase - 如何为每个用户/组的集合设置 Firebase Firestore 安全性?
- ruby-on-rails - 具有多态关联的未知属性
- ansible - ssh 密钥的 Ansible 手册:一对一、一对多、多对一