Here is the code i created to add a print button on an Infopath List edit form.
When I chaneg the location to the display form the button show fine, however when i try and put it on the
edit form it does not show. Can anyone give me a reason why it doesn't show?<CustomAction
Id="Ribbon.InfoPath.Actions.AddCustomButton"
Location="CommandUI.Ribbon.EditForm"
Title="PrintButton"
xmlns="http://schemas.microsoft.com/sharepoint/">
<CommandUIExtension xmlns="http://schemas.microsoft.com/sharepoint/">
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.ListForm.Edit.Actions.Controls._Children">
<Button Id="Ribbon.ListForm.Edit.Actions.Controls.Print"
Command="Print"
LabelText="Print Item"
Sequence="16"
TemplateAlias="o2"
Image16by16="/_layouts/images/printer.png"
Image32by32="/_layouts/images/printer.png"/>
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command="Print"
CommandAction="javascript:
var patt = /.+_FormControl.+__ViewContainer/gi;
var alldivs = document.getElementsByTagName('div');
var printpageHTML = '';
for(var i=0; i<alldivs.length; i++){
if(patt.test(alldivs[i].id)){
printpageHTML = '<HTML><HEAD>\n' +
document.getElementsByTagName('HEAD')[0].innerHTML +
'</HEAD>\n<BODY>\n' +
alldivs[i].innerHTML.replace('inline-block','block') +
'\n</BODY></HTML>';
break;
}
}
var printWindow = window.open('','printWindow');
printWindow.document.open();
printWindow.document.write(printpageHTML);
printWindow.document.close();
printWindow.print();
printWindow.close();
SP.UI.Notify.addNotification('Exiting!');
">
</CommandUIHandler>
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>