Custom Action: copy my template, not see Page
-
19-01-2021 - |
Question
I was create "SharePoint 2013 - Empty project" in Visual Studio and add module "CustomRibbonActionModule", then add HTML-Page (Module Name="CustomRibbonActionModule", File Path="CustomRibbonActionModule\HTMLPage1.html" Url="CustomRibbonActionModule/HTMLPage1.html" ):
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Description="Copy html"
Id="68275191-272b-4c59-a9ee-ee736f76f2e5"
Location="CommandUI.Ribbon"
Title="Copy template">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.EditingTools.CPEditTab.Clipboard.Controls._children">
<Button
Id="copyHtmlSelection"
Alt="Copy html"
Sequence="100"
Command="CustomRibbonButton_CopyHtml_Command"
Image16by16="/_layouts/images/NoteBoard_16x16.png"
Image32by32="/_layouts/images/NoteBoard_32x32.png"
LabelText="Copy template"
TemplateAlias="o1" />
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command="CustomRibbonButton_CopyHtml_Command"
CommandAction="javascript:var spans = $('#BD');
spans.text('');
function copy() {
var target = document.getElementById('BD');
var range, select;
if (document.createRange) {
range = document.createRange();
range.selectNode(target)
select = window.getSelection();
select.removeAllRanges();
select.addRange(range);
document.execCommand('copy');
select.removeAllRanges();
} else {
range = document.body.createTextRange();
range.moveToElementText(target);
range.select();
document.execCommand('copy');
}
}" />
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
<Module Name="CustomRibbonActionModule">
<File Path="CustomRibbonActionModule\HTMLPage1.html" Url="CustomRibbonActionModule/HTMLPage1.html" />
</Module>
</Elements>
My HTML-Page:
<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<table id="BD">
<tr class="blank_row"><td></td></tr><tr><td bgcolor='#A5DF00' style="text-align: right;">Function Requested:</td><td></td></tr><tr><td bgcolor='#FE9A2E' style="width: 300px;height: 22px;font-size: 17px">JOB RELATED INFORMATION</td><td></td></tr><tr><td bgcolor='#A5DF00' style="text-align: right;">Title</td><td bgcolor='#81BEF7'><span id="JB"></span></td></tr><tr><td bgcolor='#A5DF00' style="text-align: right;">Department</td><td bgcolor='#81BEF7'><span id="DP"></span></td></tr>
<tr><td bgcolor='#A5DF00' style="text-align: right;">Manager</td><td bgcolor='#81BEF7'><span id="MA"></span></td></tr>
<tr><td bgcolor='#A5DF00' style="text-align: right;">Notes:</td><td></td></tr>
<tr><td bgcolor='#A5DF00' style="text-align: right;">Web Page:</td><td></td></tr>
<tr class="blank_row"><td></td></tr>
<tr><td bgcolor='#FE9A2E' style="width: 300px;height: 22px;font-size: 17px">Leaver information</td><td></td></tr>
<tr><td bgcolor='#A5DF00' style="text-align: right;">Leaving date:</td><td bgcolor='#81BEF7'></td></tr>
<tr><td bgcolor='#A5DF00' style="text-align: right;">Account deletion date:</td><td bgcolor='#81BEF7'></td></tr>
<tr><td bgcolor='#A5DF00' style="text-align: right;">Mail forwarding required Yes/No:</td><td bgcolor='#81BEF7'></td></tr>
<tr><td bgcolor='#A5DF00' style="text-align: right;">File permissions rescinded Yes/No:</td><td></td></tr>
<tr><td bgcolor='#A5DF00' style="text-align: right;">Removed from All DL's:</td><td></td></tr>
<tr><td bgcolor='#A5DF00' style="text-align: right;">User machine retained Yes/No:</td><td></td></tr>
</table>
</body>
</html>
My Project not see HTML-Page, how is to fix?
Solution
Need to add mapped folder Layouts (create folder: scripts), then create file js and add xml new CustomAction:
<CustomAction
ScriptSrc="scripts/script.js"
Location="ScriptLink"
Sequence="100">
<UrlAction Url="~sites/test/SitePages/Template.aspx" />
</CustomAction>
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange