SPOnline:将 feature/asset 部署包含到我的 SPfx WebPart 后,我无法将它放在任何 SitePage 上
SPOnline: After including feature/asset deployment to my SPfx WebPart I can't put it on any SitePage
我正在尝试向我在 SharePoint Online 上的 SPfx WebPart 项目添加一些配置功能。问题是,一旦我将功能信息放入我的程序包-solution.json,配置的列表就会正确部署,但我无法在站点页面上添加 WebPart 本身。
我在 SharePoint Online 的 SPfx WebPart 项目上使用 Visual Studio 代码。我已经在我们公司的租户中部署了各种 WebParts 和扩展,但我对具有功能和资产的东西还很陌生。
我的 WebPart 需要两个特定的列表,当添加到每个 [New] -> [App] 的站点内容时,它应该自行部署。
因此,我在我的项目中添加了一个 elements.xml 和两个 schema-*.xml 文件,并修改了 package-solution.json 以将它们作为功能包含在内。
从那时起,列表已正确部署到我添加应用程序的 SiteCollection 或 SubSite。
但是(!)在编辑 SitePage 和添加 WebPart 时,WebPart 本身不会显示。它甚至不在您 select 您想要的 WebPart 的弹出窗口中。
添加应用程序时没有安装错误,SiteCollection 和 WebPart 在从包中删除功能信息时工作正常-solution.json。
我在这里,不知道出了什么问题,需要你的帮助。
包-solution.json
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "sp-bookingtool-admin",
"id": "30d57d62-8319-4b29-b0f9-***********",
"version": "2.0.0.6",
"features": [
{
"title": "sp-bookingtool-admin-features",
"description": "asset-deployment-webpart-client-side-solution",
"id": "523fe887-ced5-4036-b564-***********",
"version": "2.0.0.6",
"assets": {
"elementManifests": [
"elements.xml"
],
"elementFiles": [
"schema-sessions.xml",
"schema-courses.xml"
]
}
}
]
},
"paths": {
"zippedPackage": "solution/sp-bookingtool-admin.sppkg"
}
}
elements.xml
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListInstance
CustomSchema="schema-sessions.xml"
FeatureId="00bfea71-de22-43b2-a848-***********"
Title="BookingTool-Sessions"
Description="BookingTool-Sessions"
TemplateType="100"
Url="Lists/BookingToolSessions">
</ListInstance>
<ListInstance
CustomSchema="schema-courses.xml"
FeatureId="00bfea71-de22-43b2-a848-***********"
Title="BookingTool-Courses"
Description="BookingTool-Courses"
TemplateType="100"
Url="Lists/BookingToolCourses">
</ListInstance>
</Elements>
两个中的第一个 schema.xml
<List xmlns:ows="Microsoft SharePoint" Title="BookingTool-Courses" EnableContentTypes="TRUE" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/BookingToolCourses" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/">
<MetaData>
<Fields>
<Field ID="{1e513910-8092-45f7-b996-***********}" Name="Text_1" Type="Text" DisplayName="Text_1" Group="" Required="TRUE"/>
<Field ID="{d82721d4-0b3c-48cf-9a24-***********}" Name="Text_2" Type="Text" DisplayName="Text_2" Group="" Required="TRUE"/>
</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">
<RowLimit Paged="TRUE">30</RowLimit>
<Toolbar Type="Standard" />
<ViewFields>
<FieldRef Name="LinkTitle"></FieldRef>
</ViewFields>
<Query>
<OrderBy>
<FieldRef Name="LinkTitle" />
</OrderBy>
</Query>
</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>
感谢同事,我自己找到了错误。
出乎我的意料,ListInstances 中的 "FeatureID" 不是开发功能的 GUID,而是您使用的 Listtemplate 的 ID,具体取决于 "TemplateType"。
<ListInstance
CustomSchema="schema-sessions.xml"
FeatureId="00bfea71-de22-43b2-a848-c05709900100"
Title="BookingTool-Sessions"
Description="BookingTool-Sessions"
TemplateType="100"
Url="Lists/BookingToolSessions">
</ListInstance>
00bfea71-de22-43b2-a848-c05709900100 是自定义列表的 ID,
100 是该列表的模板类型。
我正在尝试向我在 SharePoint Online 上的 SPfx WebPart 项目添加一些配置功能。问题是,一旦我将功能信息放入我的程序包-solution.json,配置的列表就会正确部署,但我无法在站点页面上添加 WebPart 本身。
我在 SharePoint Online 的 SPfx WebPart 项目上使用 Visual Studio 代码。我已经在我们公司的租户中部署了各种 WebParts 和扩展,但我对具有功能和资产的东西还很陌生。
我的 WebPart 需要两个特定的列表,当添加到每个 [New] -> [App] 的站点内容时,它应该自行部署。 因此,我在我的项目中添加了一个 elements.xml 和两个 schema-*.xml 文件,并修改了 package-solution.json 以将它们作为功能包含在内。
从那时起,列表已正确部署到我添加应用程序的 SiteCollection 或 SubSite。 但是(!)在编辑 SitePage 和添加 WebPart 时,WebPart 本身不会显示。它甚至不在您 select 您想要的 WebPart 的弹出窗口中。
添加应用程序时没有安装错误,SiteCollection 和 WebPart 在从包中删除功能信息时工作正常-solution.json。
我在这里,不知道出了什么问题,需要你的帮助。
包-solution.json
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "sp-bookingtool-admin",
"id": "30d57d62-8319-4b29-b0f9-***********",
"version": "2.0.0.6",
"features": [
{
"title": "sp-bookingtool-admin-features",
"description": "asset-deployment-webpart-client-side-solution",
"id": "523fe887-ced5-4036-b564-***********",
"version": "2.0.0.6",
"assets": {
"elementManifests": [
"elements.xml"
],
"elementFiles": [
"schema-sessions.xml",
"schema-courses.xml"
]
}
}
]
},
"paths": {
"zippedPackage": "solution/sp-bookingtool-admin.sppkg"
}
}
elements.xml
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListInstance
CustomSchema="schema-sessions.xml"
FeatureId="00bfea71-de22-43b2-a848-***********"
Title="BookingTool-Sessions"
Description="BookingTool-Sessions"
TemplateType="100"
Url="Lists/BookingToolSessions">
</ListInstance>
<ListInstance
CustomSchema="schema-courses.xml"
FeatureId="00bfea71-de22-43b2-a848-***********"
Title="BookingTool-Courses"
Description="BookingTool-Courses"
TemplateType="100"
Url="Lists/BookingToolCourses">
</ListInstance>
</Elements>
两个中的第一个 schema.xml
<List xmlns:ows="Microsoft SharePoint" Title="BookingTool-Courses" EnableContentTypes="TRUE" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/BookingToolCourses" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/">
<MetaData>
<Fields>
<Field ID="{1e513910-8092-45f7-b996-***********}" Name="Text_1" Type="Text" DisplayName="Text_1" Group="" Required="TRUE"/>
<Field ID="{d82721d4-0b3c-48cf-9a24-***********}" Name="Text_2" Type="Text" DisplayName="Text_2" Group="" Required="TRUE"/>
</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">
<RowLimit Paged="TRUE">30</RowLimit>
<Toolbar Type="Standard" />
<ViewFields>
<FieldRef Name="LinkTitle"></FieldRef>
</ViewFields>
<Query>
<OrderBy>
<FieldRef Name="LinkTitle" />
</OrderBy>
</Query>
</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>
感谢同事,我自己找到了错误。
出乎我的意料,ListInstances 中的 "FeatureID" 不是开发功能的 GUID,而是您使用的 Listtemplate 的 ID,具体取决于 "TemplateType"。
<ListInstance
CustomSchema="schema-sessions.xml"
FeatureId="00bfea71-de22-43b2-a848-c05709900100"
Title="BookingTool-Sessions"
Description="BookingTool-Sessions"
TemplateType="100"
Url="Lists/BookingToolSessions">
</ListInstance>
00bfea71-de22-43b2-a848-c05709900100 是自定义列表的 ID, 100 是该列表的模板类型。