有人知道如何在 SharePoint 2013 JSOM 中设置 URL 字段的描述和 url 吗?
我见过的所有字段设置示例都使用 spListItem.set_item(fieldName,fieldValue)
,它非常适合文本或数字等简单字段,但在复杂的 URL 字段类型上却失败了。
我尝试传入我的 URL 字段名称和逗号分隔的 fieldValue = "descriptionText,url"
我也尝试过 SP.ListItem.parseAndSetFieldValue(fieldname,fieldValue)
,传入 URL 字段名称和逗号分隔 fieldValue = "descriptionText,url"
.
我是不是漏掉了一些简单的东西?
最佳答案
使用 SP.FieldUrlValue 对象:
function updateListItem() {
var currCtx = new SP.ClientContext();
var web = currCtx.get_web();
var lists = web.get_lists();
var myList = lists.getByTitle("List1");
myItem = myList.getItemById(3);
var urlValue = new SP.FieldUrlValue();
urlValue.set_url("http://www.example.com");
urlValue.set_description("test link");
myItem.set_item("TestURL", urlValue);
myItem.update();
currCtx.executeQueryAsync(onUpdateListSucceed,onFail);
关于javascript - 如何在 SharePoint 2013 JSOM 中设置 URL 字段的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15503654/