Sunday, August 28, 2011

Print button for Custom list with Infopath form

Scenario:
We wanted to extend the Ribbon to have a Print button for Custom list with Infopath form.

While I found so many articles to extend Ribbon UI, most of them are for a regular list / library. In SP2010, now we do have an option to use a Infopath for a custom list which uses a brand new Ribbon Tab/Grouping and I found nothing much on Web.

Solution:
Use the following Element manifest.

Code:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="InfopathformPrintButton"
Location="CommandUI.Ribbon" Rights="ViewListItems">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition
Location="Ribbon.Tabs.InfoPathListDisplayTab.Manage.Controls._children">
<Button Id="Ribbon.Tabs.InfoPathListDisplayTab.Manage.Controls.Print"
Command="CallPrint"
Sequence="1"
Description="Print the infopath form"
Image16by16="/_layouts/images/placeholder32x32.png"
Image32by32="/_layouts/images/placeholder32x32.png"
LabelText="Print"
TemplateAlias="o1"/>
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command="CallPrint"
CommandAction="javascript:function processPrint(){window.print()};processPrint();" />
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
</Elements>

5 comments:

Simran October 19, 2011 at 10:32 PM  

Could you be more specific on how to use it?
I need it badly.

Simran October 19, 2011 at 10:33 PM  

Can you explain how to use the code?
I need it badly.

Simran October 19, 2011 at 10:35 PM  

Can you explain how to use this code?
I need it badly

Sandeep K Nahta October 20, 2011 at 2:50 AM  

Simran its a Element Manifest file.
So create a feature and include this Element.xml file. Once you activate this feature , it will show up

Anonymous,  January 31, 2013 at 4:15 AM  

How to use it for New Item