我创建了一个 SharePoint 托管应用程序(Javascript 对象模型),它在主机 Web 上创建列表。
我需要将一些 javascript 放入新表单和编辑表单中,以便在 2 个查找字段上创建级联下拉效果。
以下是我为它创建列表和字段的方法:
// Create a new list on host web
var createList = function (listTitle, onSuccess, onFieldsReady) {
var listCreationInfo = new SP.ListCreationInformation();
listCreationInfo.set_title(listTitle);
listCreationInfo.set_templateType(SP.ListTemplateType.genericList);
var lists = hostWeb.get_lists();
var newList = lists.add(listCreationInfo);
currentContext.load(newList);
currentContext.executeQueryAsync(onSuccess(newList, onFieldsReady), onListCreationFail);
}
// Create a new field on a list
var createField = function (list, fieldType, fieldName, fieldDisplayName, fieldRequired, onSuccess) {
var fields = list.get_fields();
var fieldXml = "<Field Type='" + fieldType + "' Required='" + fieldRequired + "' DisplayName='" + fieldDisplayName + "' Name='" + fieldName + "'></Field>";
var createdField = fields.addFieldAsXml(fieldXml, true, SP.AddFieldOptions.addFieldInternalNameHint | SP.AddFieldOptions.addFieldToDefaultView);
currentContext.load(createdField);
currentContext.executeQueryAsync(onSuccess, onProvisionFieldFail);
}
你能给我一些建议吗?
问候,
玛丽安