SharePoint o365 自定义功能区操作
SharePoint o365 Custom Ribbon Action
我创建了一个 SP 托管应用..然后我添加了一个功能区自定义操作并选择了 "Host Web"
我添加了以下内容XML:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="cautionIcon"
Location="CommandUI.Ribbon">
<CommandUIExtension>
<!--
Update the UI definitions below with the controls and the command actions
that you want to enable for the custom action.
-->
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.EditingTools.CPInsert.Groups._children">
<Group
Id="UploadLinkRibbonActionGroup"
Sequence="80"
Description="This group will contain the Button control"
Title="Caution"
Template="Ribbon.Templates.Flexible2">
<Controls Id="UploadLinkControl">
<Button
Id="CautionButton"
Command="UploadLinkButtonCommand"
Image32by32="/sites/insightdeveloper/PublishingImages/mrT32.png"
LabelText="Caution"
TemplateAlias="o1"
Sequence="10"/>
</Controls>
</Group>
</CommandUIDefinition>
<CommandUIDefinition
Location="Ribbon.EditingTools.CPInsert.Scaling._children">
<MaxSize
Id="CustomEditRibbonActionsOneMaxSize"
Sequence="15"
GroupId="UploadLinkRibbonActionGroup"
Size="LargeLarge"/>
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler Command="UploadLinkButtonCommand"
CommandAction="~appWebUrl/Pages/Default.aspx?{StandardTokens}"/>
</CommandUIHandlers>
</CommandUIExtension >
这确实在我的功能区中添加了一个按钮。
问题是我无法在更改 CommandAction= 中的 ~appWebUrl 后立即调用任何自定义 JS 我在尝试部署时遇到错误。 "There were errors when validating the App Package"。
我希望能够在命令操作中添加一些 JS "javascript:alert('hello');",但是一旦缺少 ~appWebUrl,我就会收到错误消息。我在 SP 2010 中没有这个问题,这很容易。
感谢任何帮助!
在 SharePoint 2013 中,自定义操作 URL 必须以 "http:"、"https:"、“~appWebUrl”或“~remoteAppUrl”开头。 SharePoint 2010 它工作正常。检查以下内容:
"CustomAction cannot contain JavaScript: Any UrlActions or CommandActions must be a URL to navigate to. The URL can be parameterized with normal custom actions tokens in addition to the app-specific tokens." 来自这里:
https://msdn.microsoft.com/en-us/library/jj220046.aspx?f=255&MSPPError=-2147217396
我创建了一个 SP 托管应用..然后我添加了一个功能区自定义操作并选择了 "Host Web"
我添加了以下内容XML:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="cautionIcon"
Location="CommandUI.Ribbon">
<CommandUIExtension>
<!--
Update the UI definitions below with the controls and the command actions
that you want to enable for the custom action.
-->
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.EditingTools.CPInsert.Groups._children">
<Group
Id="UploadLinkRibbonActionGroup"
Sequence="80"
Description="This group will contain the Button control"
Title="Caution"
Template="Ribbon.Templates.Flexible2">
<Controls Id="UploadLinkControl">
<Button
Id="CautionButton"
Command="UploadLinkButtonCommand"
Image32by32="/sites/insightdeveloper/PublishingImages/mrT32.png"
LabelText="Caution"
TemplateAlias="o1"
Sequence="10"/>
</Controls>
</Group>
</CommandUIDefinition>
<CommandUIDefinition
Location="Ribbon.EditingTools.CPInsert.Scaling._children">
<MaxSize
Id="CustomEditRibbonActionsOneMaxSize"
Sequence="15"
GroupId="UploadLinkRibbonActionGroup"
Size="LargeLarge"/>
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler Command="UploadLinkButtonCommand"
CommandAction="~appWebUrl/Pages/Default.aspx?{StandardTokens}"/>
</CommandUIHandlers>
</CommandUIExtension >
这确实在我的功能区中添加了一个按钮。
问题是我无法在更改 CommandAction= 中的 ~appWebUrl 后立即调用任何自定义 JS 我在尝试部署时遇到错误。 "There were errors when validating the App Package"。
我希望能够在命令操作中添加一些 JS "javascript:alert('hello');",但是一旦缺少 ~appWebUrl,我就会收到错误消息。我在 SP 2010 中没有这个问题,这很容易。
感谢任何帮助!
在 SharePoint 2013 中,自定义操作 URL 必须以 "http:"、"https:"、“~appWebUrl”或“~remoteAppUrl”开头。 SharePoint 2010 它工作正常。检查以下内容:
"CustomAction cannot contain JavaScript: Any UrlActions or CommandActions must be a URL to navigate to. The URL can be parameterized with normal custom actions tokens in addition to the app-specific tokens." 来自这里: https://msdn.microsoft.com/en-us/library/jj220046.aspx?f=255&MSPPError=-2147217396