Sharepoint &引用;“无法完成此操作”;尝试使用site TaxonomyField设置列表实例时
公平警告:这个问题的设置很长,请耐心等待 我的解决方案包中有两个功能。第一个是一组站点字段和内容类型;让我们将这一特性称为A。字段中有一个类型为“TaxonomyFieldType”的字段和一个类型为“Note”()的关联字段 第二个特性包含列表模板和实例,其中一个使用上述内容类型;我们把这个功能称为功能B 以下是列表的列表架构,在设置时会弹出(Sharepoint &引用;“无法完成此操作”;尝试使用site TaxonomyField设置列表实例时,sharepoint,content-type,list-definition,Sharepoint,Content Type,List Definition,公平警告:这个问题的设置很长,请耐心等待 我的解决方案包中有两个功能。第一个是一组站点字段和内容类型;让我们将这一特性称为A。字段中有一个类型为“TaxonomyFieldType”的字段和一个类型为“Note”()的关联字段 第二个特性包含列表模板和实例,其中一个使用上述内容类型;我们把这个功能称为功能B 以下是列表的列表架构,在设置时会弹出(ListInstance元素未显示): main.xsl 30 部署解决方案后,我可以毫无问题地激活功能。将创建站点列和内容类型。当我尝试激活功能B
ListInstance
元素未显示):
main.xsl
30
部署解决方案后,我可以毫无问题地激活功能。将创建站点列和内容类型。当我尝试激活功能B时,功能激活调用堆栈会爆炸,并导致一个带有以下堆栈跟踪的错误页面:
[COMException (0x80004005): Cannot complete this action.
Please try again.]
Microsoft.SharePoint.Library.SPRequestInternalClass.UpdateField(String bstrUrl, String bstrListName, String bstrXML) +0
Microsoft.SharePoint.Library.SPRequest.UpdateField(String bstrUrl, String bstrListName, String bstrXML) +134
[SPException: Cannot complete this action.
Please try again.]
Microsoft.SharePoint.Administration.SPElementDefinitionCollection.ProvisionListInstances(SPFeaturePropertyCollection props, SPSite site, SPWeb web, Boolean fForce) +23649702
Microsoft.SharePoint.Administration.SPElementDefinitionCollection.ProvisionElements(SPFeaturePropertyCollection props, SPWebApplication webapp, SPSite site, SPWeb web, Boolean fForce) +197
Microsoft.SharePoint.SPFeature.Activate(SPSite siteParent, SPWeb webParent, SPFeaturePropertyCollection props, Boolean fForce) +25437263
Microsoft.SharePoint.SPFeatureCollection.AddInternal(SPFeatureDefinition featdef, Version version, SPFeaturePropertyCollection properties, Boolean force, Boolean fMarkOnly) +27496735
Microsoft.SharePoint.SPFeatureCollection.AddInternalWithName(Guid featureId, String featureName, Version version, SPFeaturePropertyCollection properties, Boolean force, Boolean fMarkOnly, SPFeatureDefinitionScope featdefScope) +150
Microsoft.SharePoint.SPFeatureCollection.Add(Guid featureId, Boolean force, SPFeatureDefinitionScope featdefScope) +83
Microsoft.SharePoint.WebControls.FeatureActivator.ActivateFeature(Guid featid, SPFeatureDefinitionScope featdefScope) +699
Microsoft.SharePoint.WebControls.FeatureActivatorItem.BtnActivateFeature_Click(Object objSender, EventArgs evtargs) +140
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +115
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +140
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981
[COMException(0x80004005):无法完成此操作。
请再试一次。]
Microsoft.SharePoint.Library.SPRequestInternalClass.UpdateField(字符串bstrUrl、字符串bstrListName、字符串bstrXML)+0
Microsoft.SharePoint.Library.SPRequest.UpdateField(字符串bstrUrl,字符串bstrListName,字符串bstrXML)+134
[SPException:无法完成此操作。
请再试一次。]
Microsoft.SharePoint.Administration.SPElementDefinitionCollection.ProvisionListInstances(SPFeaturePropertyCollection道具、SPSite网站、SPWeb web、布尔fForce)+23649702
Microsoft.SharePoint.Administration.SPElementDefinitionCollection.ProvisionElements(SPFeaturePropertyCollection道具、SPWebApplication webapp、SPSite站点、SPWeb web、Boolean fForce)+197
Microsoft.SharePoint.SPFeature.Activate(SPSite站点父级、SPWeb网页租金、SPFeaturePropertyCollection道具、布尔fForce)+25437263
Microsoft.SharePoint.SPFeatureCollection.AddInternal(SPFeatureDefinition FeatureDef,版本,SPFeatureProperty集合属性,布尔值强制,布尔值仅标记)+27496735
Microsoft.SharePoint.SPFeatureCollection.AddInernalWithName(Guid featureId、字符串featureName、版本、SPFeaturePropertyCollection属性、布尔强制、布尔fMarkOnly、SPFeatureDefinitionScope FeatureDefScope)+150
Microsoft.SharePoint.SPFeatureCollection.Add(Guid featureId、布尔力、SPFeatureDefinitionScope FeatureDefScope)+83
Microsoft.SharePoint.WebControl.FeatureActivator.ActivateFeature(Guid FeatureID,SPFeatureDefinitionScope FeatureDefScope)+699
Microsoft.SharePoint.WebControl.FeatureActivatorItem.BtnActivateFeature_单击(对象对象objSender,事件参数evtargs)+140
System.Web.UI.WebControls.Button.OnClick(EventArgs e)+115
System.Web.UI.WebControl.Button.RaisePostBackEvent(String eventArgument)+140
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl,String eventArgument)+29
System.Web.UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)+2981
我相当确定我在功能A中配置
分类字段的方式有问题;它在资源调配时与列表实例的关联是错误的原因(我通过注释出片段并反复部署来确定这一点)。对于TaxonomyFields
并在列表实例中提供它们,似乎没有什么文档,甚至博客作者的经验,所以我有点不知所措。有人知道出了什么问题吗?我跟在维克托·威尔恩后面,能够得到类似的结果(请确保也从中进行了修改)。我跟在维克托·威尔恩后面,能够得到类似的结果(请确保也从中进行了修改).为了解决这个问题,我最终与微软展开了一次支持事件。最终,他们的服务代表跟踪到在列表模板上设置属性DisallowContentTypes=“FALSE”
,在列表架构上设置属性EnableContentTypes=“TRUE”
。这解决了我的资源调配问题
但是,我仍然无法在新设置的列表上实际创建项,这与必须伴随分类字段(grrr)的隐藏文本字段有关。我已经在站点中设置了一个注释字段,并且在列表模板中引用了它,并且在站点列定义和字段定义中将TextField属性设置为该注释字段的ID
Wictor提到了这一点(如果我记得读过他的帖子的话),但这里还有更多:
我目前被困在项目创建时抛出的异常上,说:
无法获取“标记”的值
“托管元数据”中的列
字段类型控制。请参阅中的详细信息
日志异常消息:无效字段
名称
{956a1078-ec35-4c04-83c4-0a3742119496}
/站点/mysite/列表/条目
最后,我与微软展开了一次支持事件,以解决这个问题。最终,他们的服务代表跟踪到在列表模板上设置属性DisallowContentTypes=“FALSE”
,在列表架构上设置属性EnableContentTypes=“TRUE”
。这解决了我的资源调配问题
但是,我仍然无法在新设置的列表上实际创建项,这与必须伴随分类字段(grrr)的隐藏文本字段有关。我已经在站点中设置了一个注释字段,并且在列表模板中引用了它,并且在站点列定义和字段定义中将TextField属性设置为该注释字段的ID
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- Parent ContentType: Item (0x01) -->
<ContentType ID="0x0100b61c774f4c0e4a89bf230cbb44cd4f75"
Name="MyContent"
Group="MyGroup"
Description="Description of My Content Type"
Inherits="FALSE"
Overwrite="TRUE"
Version="0">
<FieldRefs>
<FieldRef ID="{52578fc3-1f01-4f4d-b016-94ccbcf428cf}" DisplayName="Comments" Name="Comments" Required="FALSE"/>
<FieldRef ID="{956a1078-ec35-4c04-83c4-0a3742119496}" Name="TimeTrackerTaxonomyTextField"/>
<FieldRef ID="{92BC866B-0415-45F0-B431-D4DF69C421CC}" DisplayName="Tags" Name="Tags" Required="FALSE"/>
</FieldRefs>
</ContentType>
</Elements>
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPWeb web = GetWebObj(properties.Feature.Parent);
Guid fieldId = new Guid("92BC866B-0415-45F0-B431-D4DF69C421CC");
TaxonomyField field = web.Fields[fieldId] as TaxonomyField;
string groupName = properties.Feature.Properties["TaxonomyGroupName"].Value;
string termSetName = properties.Feature.Properties["TermSetName"].Value;
DiagnosticService logger = DiagnosticService.Local;
TermSet set = null;
TaxonomySession session = new TaxonomySession(web.Site);
TermSetCollection termSets = session.GetTermSets(termSetName, System.Threading.Thread.CurrentThread.CurrentUICulture.LCID);
if (termSets == null || termSets.Count == 0)
{
logger.WriteTrace(1, logger[CategoryId.Deployment], TraceSeverity.Medium,
"Activity Tags term set not found. Ensuring '{0}' group and '{1}' term set.", groupName, termSetName);
// create the term set in the default store
var store = session.DefaultSiteCollectionTermStore;
var group = store.EnsureGroup(groupName);
set = group.EnsureTermSet(termSetName);
store.CommitAll();
logger.WriteTrace(1, logger[CategoryId.Provisioning], TraceSeverity.Verbose, "created taxonomy group '{0}' and term set '{1}'", group, set);
}
else
{
logger.WriteTrace(1, logger[CategoryId.Deployment], TraceSeverity.Verbose, "term set found.");
// need to make sure we grab the one in the right group, or it might be someone else's term set.
foreach (var termSet in termSets)
{
if (String.Equals(termSet.Group.Name,groupName))
{
if (set == null)
{
set = termSet;
}
else
{
logger.WriteTrace(1, logger[CategoryId.Deployment], TraceSeverity.Unexpected,
"Multiple term sets named '{0}' found in more than one taxonomy group.", termSetName);
throw new SPException(String.Format("Multiple term sets named '{0}' found in more than one taxonomy group. "+
"Was there a previous installation that was not removed properly?", termSetName));
}
}
}
if (set == null)
{
// term set found, but in an unrecognized group. leave it alone and do like above
logger.WriteTrace(1, logger[CategoryId.Deployment], TraceSeverity.Verbose,
"Term set '{0}' found, but in unrecognized group. Provisioning new group and term set as configured.", termSetName);
var store = session.DefaultSiteCollectionTermStore;
var group = store.EnsureGroup(groupName);
set = group.EnsureTermSet(termSetName);
store.CommitAll();
logger.WriteTrace(1, logger[CategoryId.Provisioning], TraceSeverity.Verbose, "created taxonomy group '{0}' and term set '{1}'", group, set);
}
}
// set termSets to the newly created term set
field.SspId = set.TermStore.Id;
field.TermSetId = set.Id;
field.TargetTemplate = String.Empty;
field.AnchorId = Guid.Empty;
field.Open = true;
field.AllowMultipleValues = true;
field.Update();
}
<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint" Title="My List" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/MyList" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/">
<MetaData>
<ContentTypes>
<ContentTypeRef ID="0x0100b61c774f4c0e4a89bf230cbb44cd4f75"></ContentTypeRef>
</ContentTypes>
<Fields>
<Field ID="{956a1078-ec35-4c04-83c4-0a3742119496}" Name="TaxonomyTextField" Type="Note"/>
<Field ID="{92bc866b-0415-45f0-b431-d4df69c421cc}" Name="Tags" Type="TaxonomyFieldType"/>
<Field ID="{52578FC3-1F01-4f4d-B016-94CCBCF428CF}" Name="_Comments" Type="Note"/>
</Fields>
<Views>
<View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/generic.png" Url="AllItems.aspx">
<Toolbar Type="Standard" />
<XslLink Default="TRUE">main.xsl</XslLink>
<RowLimit Paged="TRUE">30</RowLimit>
<ViewFields>
<!-- <FieldRef Name="Tags"></FieldRef> -->
<FieldRef Name="_Comments"></FieldRef>
</ViewFields>
<Query>
<OrderBy>
<FieldRef Name="ID">
</FieldRef>
</OrderBy>
</Query>
<ParameterBindings>
<ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
<ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
</ParameterBindings>
</View>
</Views>
<Forms>
<Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
<Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
<Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
</Forms>
</MetaData>
</List>
[COMException (0x80004005): Cannot complete this action.
Please try again.]
Microsoft.SharePoint.Library.SPRequestInternalClass.UpdateField(String bstrUrl, String bstrListName, String bstrXML) +0
Microsoft.SharePoint.Library.SPRequest.UpdateField(String bstrUrl, String bstrListName, String bstrXML) +134
[SPException: Cannot complete this action.
Please try again.]
Microsoft.SharePoint.Administration.SPElementDefinitionCollection.ProvisionListInstances(SPFeaturePropertyCollection props, SPSite site, SPWeb web, Boolean fForce) +23649702
Microsoft.SharePoint.Administration.SPElementDefinitionCollection.ProvisionElements(SPFeaturePropertyCollection props, SPWebApplication webapp, SPSite site, SPWeb web, Boolean fForce) +197
Microsoft.SharePoint.SPFeature.Activate(SPSite siteParent, SPWeb webParent, SPFeaturePropertyCollection props, Boolean fForce) +25437263
Microsoft.SharePoint.SPFeatureCollection.AddInternal(SPFeatureDefinition featdef, Version version, SPFeaturePropertyCollection properties, Boolean force, Boolean fMarkOnly) +27496735
Microsoft.SharePoint.SPFeatureCollection.AddInternalWithName(Guid featureId, String featureName, Version version, SPFeaturePropertyCollection properties, Boolean force, Boolean fMarkOnly, SPFeatureDefinitionScope featdefScope) +150
Microsoft.SharePoint.SPFeatureCollection.Add(Guid featureId, Boolean force, SPFeatureDefinitionScope featdefScope) +83
Microsoft.SharePoint.WebControls.FeatureActivator.ActivateFeature(Guid featid, SPFeatureDefinitionScope featdefScope) +699
Microsoft.SharePoint.WebControls.FeatureActivatorItem.BtnActivateFeature_Click(Object objSender, EventArgs evtargs) +140
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +115
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +140
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981
<ContentTypes>
<ContentTypeRef ID="0x01"></ContentTypeRef>
</ContentTypes>
public static string ConfigureCustomListForCustomContentType(SPWeb web, string strListName, string strCustomContentTypeName)
{
StringBuilder sbOutput = new StringBuilder();
try
{
SPList customlist = web.Lists[strListName];
SPContentType CustomContentType = null;
//Validate Content Types
//1) Find the Content Type in the Content Type list
foreach (SPContentType spct in web.Site.RootWeb.ContentTypes)
{
if (spct.Name == strCustomContentTypeName)
{
CustomContentType = spct;
break;
}
}
if (CustomContentType == null)
{
sbOutput.Append("<div class='error'>Unable to find custom content type named " + strCustomContentTypeName +".</div>");
return sbOutput.ToString();
}
sbOutput.Append("Found content Type "+CustomContentType.Name+"...<br />");
Boolean bFoundContentType = false;
customlist.ContentTypesEnabled = true;
List<SPContentTypeId> RemoveContentTypeList = new List<SPContentTypeId>();
//Remove all other content types
foreach (SPContentType spct in customlist.ContentTypes)
{
if (spct.Name == strCustomContentTypeName)
{
bFoundContentType = true;
}
else
{
RemoveContentTypeList.Add(spct.Id);
}
}
if (!bFoundContentType)
{
sbOutput.Append("Adding [" + strCustomContentTypeName + "] to List " + customlist.Title + "<br />");
customlist.ContentTypes.Add(CustomContentType);
}
else
{
sbOutput.Append("[" + strCustomContentTypeName + "] already in List " + customlist.Title + ".<br />");
}
for (int i = 0; i < RemoveContentTypeList.Count; i++)
{
sbOutput.Append("Removing extra content type: " + customlist.ContentTypes[RemoveContentTypeList[i]].Name + "<br />");
customlist.ContentTypes[RemoveContentTypeList[i]].Delete();
}
}
catch (Exception ex)
{
sbOutput.Append("<div class='error'>Error occurred configuring "+strListName+": " + ex.ToString() + "<br /></div>");
}
return sbOutput.ToString();
}