我在SharePoint列表中出现问题 - 某些字段在显示窗体,新建项目窗体和列表设置页面上显示两次。这两个字段具有相同的ID和相同的属性页面(相同的URL),因此隐藏一个隐藏另一个。
使用SharePoint Manager我只能看到一个字段,但也许我看了错误的地方? 有没有人经历过类似的事情,我该如何解决这个问题?Sharepoint - 字段在查看/新项目上出现两次
回答
更新创建内容类型的xml并不明智。如果您想稍后添加字段到内容类型,请通过新功能执行此操作,请参阅此链接。
请注意下面的文本
在任何情况下,你应该更新的内容类型的内容类型定义文件已安装并激活该内容类型之后。 Windows SharePoint Services不会跟踪对内容类型定义文件所做的更改。因此,您没有办法将对站点内容类型所做的更改推送到子内容类型。 有关更改已安装和激活的内容类型时的最佳做法的信息,请参阅更新内容类型。
Yepp,我已经遇到了将这些内容类型添加到列表中的问题。当我以某种方式更新内容类型时,我有时会得到重复的内容。当我看着他们,他们似乎是相同的ID和名字,但ID实际上是不同的。
我用过的解决方案(至少与contenttypes一起使用)是将网站contenttypes上的字段链接与包含contenttype的实际xml文件(feature)中的字段链接进行比较。如果它们的字段链接数不相同...请执行操作以删除重复项。
Hello Johan,谢谢!你是绝对正确的,顺便说一句,这是一个内容类型添加到列表的功能(不是我的,但)。我在哪里可以找到这些fieldlinks?它是否以编程方式完成? – Kobi 2009-06-10 08:45:25
我的意思是
我得到了同样的问题,在列表定义中添加列后,他们开始出现在新/编辑/查看项目形式两次。我只是改变了列表设置的列顺序,问题解决了。
有趣的解决方法,谢谢。我实际上知道SharePoint中的几个问题可以通过完全解决...... – Kobi 2011-08-22 14:37:42
使用此PowerShell脚本来清洁dublicates:
Clear-Host
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
$web=Get-SPWeb "http://weburl.here"
function cleanFieldLinks($listName){
$list = $web.GetList($listName)
$ct = $list.ContentTypes[0];
$flDub = $ct.FieldLinks | group-object DisplayName | where { $_.Count -gt 1 }
foreach($fl in $flDub) {
$skipFirst = $fl.Group | select-object -skip 1
foreach($flDel in $skipFirst){
$ct.FieldLinks.Delete($flDel.Id)
}
}
$ct.Update()
}
cleanFieldLinks("lists/listurl")
$web.Dispose()
1)首先,我想提一提,我碰到这个问题,因为我是对我做MOSS 2007的解决方案包MOSS 2013年MOSS兼容工作2013似乎不喜欢重复的字段名称。因此,如果您的自定义字段具有与MOSS 2013一起提供的字段相同的名称,则会发现重复的字段名称被发现错误。
2)这迫使我不得不返回并更新我的自定义字段和内容类型。在对造成重复字段名称问题的自定义字段进行更改后,我发现我的字段名称多次出现的问题。
3)我写了一个web表单页面来解决在视图,新建和编辑表单上多次显示该字段的问题。你只需要修改代码来指定你想要检查的列表。此版本将删除fieldref的第一个实例并保留第二个实例:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
//using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
//using System.Xml.Linq;
using Microsoft.SharePoint;
using System.Text;
using System.Collections.Generic;
public partial class FixDuplicateFieldIssue : Microsoft.SharePoint.WebControls.LayoutsPageBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (SPContext.Current.Web.CurrentUser == null)
{
Response.Write("You must be logged in to view this page.");
Response.End();
return;
}
if (!SPContext.Current.Web.DoesUserHavePermissions(SPBasePermissions.ManageWeb))
{
Response.Write("You do not have permissions to view this page.");
Response.End();
return;
}
lblOutput.Text = "";
StringBuilder sbOutput = new StringBuilder();
using (SPSite site = new SPSite(SPContext.Current.Site.ID))
{
using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))
{
try
{
hlBack.NavigateUrl = web.Url;
//open the List **** SPECIFY THE LISTNAME HERE ***
SPList spList = web.Lists["LISTNAME"];
if (spList != null)
{
//Check FieldLinks
sbOutput.Append("<table border='1'>");
foreach (SPContentType ct in spList.ContentTypes)
{
sbOutput.Append("<tr>");
sbOutput.Append("<td>" + ct.Name + "</td>");
sbOutput.Append("<td>");
Dictionary<string, Guid> GuidDictionary = new Dictionary<String, Guid>();
List<Guid> RepeatList = new List<Guid>();
//SEARCH THE CONTENT TYPE FOR REPEAT SPFieldLinks
foreach (SPFieldLink spfl in ct.FieldLinks)
{
if (!GuidDictionary.ContainsKey(spfl.Name.ToLower()))
{
GuidDictionary.Add(spfl.Name.ToLower(), spfl.Id);
}
else if (GuidDictionary[spfl.Name.ToLower()].ToString().ToLower()!=spfl.Id.ToString().ToLower())
{
//Record the GUID of the repeat SPFieldLink you want to delete in the RepeatList. In this case, we're recording the first item. If you want to delete the second one, add the spfl.Id instead.
RepeatList.Add(GuidDictionary[spfl.Name.ToLower()]);
sbOutput.Append("<span style='color:red;'>*</span>");
}
sbOutput.Append(spfl.Name + "," + spfl.Id + "," + spfl.DisplayName +"<br />");
}
sbOutput.Append("</td>");
sbOutput.Append("<td>");
sbOutput.Append("Repeats found: " + RepeatList.Count + "<br />");
//DELETE THE Repeat Field Links
foreach (Guid idToDelete in RepeatList)
{
sbOutput.Append("Deleting FieldRef with ID= " + idToDelete.ToString() + "<br />");
web.AllowUnsafeUpdates = true;
ct.FieldLinks.Delete(idToDelete);
ct.Update();
web.AllowUnsafeUpdates = false;
}
sbOutput.Append("</td>");
sbOutput.Append("</tr>");
}
sbOutput.Append("</table>");
}
}
catch (Exception ex)
{
sbOutput.Append("Error Occurred: " + ex.ToString());
}
}
}
lblOutput.Text = sbOutput.ToString();
}
}
- 1. 如何在SharePoint 2010上查看项目
- 2. 发现无:字段在表中出现两次或两次以上
- 3. 对项目的SharePoint 2010工作流更新查找字段
- 4. Sharepoint工作流创建新任务项目两次? (SP 2007)
- 5. Drupal 6.20,查看节点时出现字段时出现编辑
- 6. 动态表格输出 - 每个字段在出现前会出现两次
- 7. 查看某个项目是否在数据库列中多次出现
- 8. Laravel查询生成器如何检查项目是否出现两次
- 9. 项目两次
- 10. ListFragment在手机上出现两次
- 11. 正在更新收藏查看项目
- 12. 在浏览器上查看项目
- 13. 查找在Javascript数组中只出现一次的项目
- 14. 我如何打开eclipse并查看我上次查看的项目视图?
- 15. 动画查看每次查看控制器出现?
- 16. 合并两个列表,每个项目出现一次
- 17. Winform出现两次
- 18. 刷新时出现错误在SurfaceView上查看
- 19. 无法在angular-cli新项目上查看代码覆盖
- 20. 在Sharepoint创建一次字段
- 21. 针对多个上次查看项目的推荐
- 22. 防止项目再次出现错误
- 23. 查看项目在Eclipse - SVN
- 24. SharePoint AJAX实现:ScriptHandler被添加两次
- 25. asp.net mvc 2查看扩展,新项目
- 26. 文本字段中出现多次UItableViewGrouped
- 27. SQL语句只选择出现次数少于两次的项目
- 28. 在django中查看两次发起
- 29. 更改Django的主键字段,现在项目不会出现在管理员
- 30. 在SharePoint 2007新建项目表单中创建自定义字段
生产中存在的问题,我们有真实的数据。我们创建了新列并将数据复制到它们,并删除了重复的列。所以,从某种意义上说,您的解决方案就是我们所做的 - 什么都不是:-) – Kobi 2009-06-11 08:12:43