我在SharePoint中有两个列表,每个列表都有两列:
列表A
第1列 ----------- 第2列
Bob ------------------- Apple
Joe -------------------橙色
简------------------香蕉
列表B
第3列 ----------- 第4列
列表B的第3列是对列表A的第1列的查找,因此在第3列中有一个下拉名称列表。
我现在想设置第4列以使用列表A中第2列中的相关数据自动填充(即,如果我在第3列中选择“鲍勃”,则第4列将填充“苹果”。如果我选择“第3列,第4列中的“ Joe”将填充“ Orange”,依此类推)。我认为这应该是一个计算值,但不确定。
从本质上讲,是否可以将计算列的值设置为来自另一个列表的数据?或者我还能怎么做?这将是一个工作流程吗?我正在使用SharePoint 2013,可以直接使用,也可以执行工作流。谢谢!
答案 0 :(得分:0)
与this thread类似的要求,因此当列3更改列表新/编辑形式时,您可以使用JavaScript填充列4。
$(document).ready(function () {
var ID;
$('select[title= "Name"]').change(function () {
ID = $('select[title= "Name"] option:selected').val();
$().SPServices({
operation: "GetListItems",
async: false,
listName: "Test",
CAMLViewFields: "<ViewFields><FieldRef Name='Country'/>, <FieldRef Name='Location'/>,<FieldRef Name='Mobile'/>,<FieldRef Name='Manager'/> </ViewFields>",
CAMLQuery: "<Query><Where><Eq><FieldRef Name='ID'/><Value Type='Counter'>" + ID + "</Value></Eq></Where></Query>",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function () {
var Country = $(this).attr("ows_Country");
$('input[title="Country"]').val(Country);
$("input[Title='Country']").attr("disabled", "disabled");
var Location = $(this).attr("ows_Location");
$('input[title="Location"]').val(Location);
$("input[Title='Location']").attr("disabled", "disabled");
var Mobile = $(this).attr("ows_Mobile");
$('input[title="Mobile"]').val(Mobile);
$("input[Title='Mobile']").attr("disabled", "disabled");
var Manager = $(this).attr("ows_Manager");
Manager = Manager.replace(/[^a-z ;]/gi, '');
var re = /;;/gi;
var re1 = / /gi;
Manager1 = Manager.replace(re, ';');
Manager1 = Manager1.replace(re1, ', ');
Manager1 = Manager1.substring(1);
$('input[title="Manager"]').val(Manager1);
$("input[Title='Manager']").attr("disabled", "disabled");
});
}
});
});
});