Thursday, December 23, 2010

SharePoint 2010 Site Templates Document Library Workflow + OneNote

I ran across a strange problem today. Here's my situation. Saving a site as a site template (wsp solution), the site had a document library that had a default template of a OneNote file and it also had workflow associated with it (created with SPD). Using the site template to recreate the file works but the document library's "New Document" button was disabled and there was no template associated with it in the new site.

I wrote a bit of code that resets the document library to use the OneNote document as its template but the question remains, why did that button get greyed out when a workflow was associated with that document library and saved in the template.

I tested saving the template without the workflow associated with the document library and the OneNote template stayed associated with the document library, it was only when I associated a workflow with the document library that the "New Document" button got greyed out.

Bug!

Monday, December 6, 2010

OneNote Publish to PDF

Microsoft.Office.Interop.OneNote Publish. To publish the entire notebook, use the code below, where Personal is the name and folder of my notebook. The Publish action will find all the .one files and combine them into one pdf file. Whammooo!!

var onenoteApp = new Microsoft.Office.Interop.OneNote.Application();

string bstrHierarchyID = string.Empty;
onenoteApp.OpenHierarchy(@"C:\Users\brad.test\Documents\OneNote Notebooks\Personal\",
System.String.Empty, out bstrHierarchyID, Microsoft.Office.Interop.OneNote.CreateFileType.cftNone);

string bstrTargetFilePath = "C:\\Temp\\Personal1.pdf";

onenoteApp.Publish(bstrHierarchyID, bstrTargetFilePath, OneNote.PublishFormat.pfPDF);

Monday, November 15, 2010

SharePoint EditControlBlock RegistrationId types

public enum SPListTemplateType
{
InvalidType = -1,
GenericList = 100,
DocumentLibrary = 101,
Survey = 102,
Links = 103,
Announcements = 104,
Contacts = 105,
Events = 106,
Tasks = 107,
DiscussionBoard = 108,
PictureLibrary = 109,
DataSources = 110,
WebTemplateCatalog = 111,
UserInformation = 112,
WebPartCatalog = 113,
ListTemplateCatalog = 114,
XMLForm = 115,
MasterPageCatalog = 116,
NoCodeWorkflows = 117,
WorkflowProcess = 118,
WebPageLibrary = 119,
CustomGrid = 120,
DataConnectionLibrary = 130,
WorkflowHistory = 140,
GanttTasks = 150,
Meetings = 200,
Agenda = 201,
MeetingUser = 202,
Decision = 204,
MeetingObjective = 207,
TextBox = 210,
ThingsToBring = 211,
HomePageLibrary = 212,
Posts = 301,
Comments = 302,
Categories = 303,
IssueTracking = 1100,
AdminTasks = 1200,
}

Thursday, November 11, 2010

SharePoint 2010 Backward Compatible Document Library Events

They still work. Hooray!!

When I go to the SharePoint 2010 document library settings I can see:

Specify the assembly name, class name and properties for the document library's event handler. WSS_LONG_NAME will call this event handler when items in the document library are inserted, updated, or deleted.

Not sure what "WSS_LONG_NAME" is but apparently it will call my SharePoint 2010 document library event handler.

To enable this to show, I went to Central Admin of my SharePoint 2010 farm, Manage Web Applications, select the web application and then click on Resource Throttling. There will be a radio button to turn this (backward compatible document library events) on or off.

Tuesday, November 9, 2010

SharePoint 2010 Common Navigation Across Site Collections

So Microsoft best practice dictates content dbs should be less than 100GB or so, at least that's what I think. Either way, you're here because you have multiple site collections and want to know how to have the same top navigation bar across all the site collections. It took me a few hours to find but here's the solution.

In web.config file, add the following provider


<siteMap defaultProvider="CurrentNavigation" enabled="true">

<providers>

<add name="CustomTopNavProvider" siteMapFile="/_layouts/1033/CustomTopNavMenu.sitemap" type="System.Web.XmlSiteMapProvider,System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>





Add the CustomTopNavMenu.sitemap to the 1033 directory. If you don't know how to create or use a sitemap file just google it.

Open up the master page for each site collection, for 2010 it's v4, probably best to create a copy and all that stuff before editing it.

Find this part of the file. (around line 343)




<SharePoint:AspMenu

  ID="TopNavigationMenuV4"

  Runat="server"

  EnableViewState="false"

  DataSourceID="topSiteMap"

  AccessKey="<%$Resources:wss,navigation_accesskey%>"

  UseSimpleRendering="true"

  UseSeparateCss="false"

  Orientation="Horizontal"

  StaticDisplayLevels="2"

  MaximumDynamicDisplayLevels="1"

  SkipLinkText=""

  CssClass="s4-tn"/>

<SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource" Id="topNavigationDelegate">

<Template_Controls>

<asp:SiteMapDataSource

  ShowStartingNode="False"

  SiteMapProvider="SPNavigationProvider"

  id="topSiteMap"

  runat="server"

  StartingNodeUrl="sid:1002"/>

</Template_Controls>

</SharePoint:DelegateControl>





and change it to the following:


<SharePoint:AspMenu

  ID="TopNavigationMenuV4"

  Runat="server"

  EnableViewState="false"

  DataSourceID="topSiteMap"

  AccessKey="<%$Resources:wss,navigation_accesskey%>"

  UseSimpleRendering="true"

  UseSeparateCss="false"

  Orientation="Horizontal"

  StaticDisplayLevels="1"

  MaximumDynamicDisplayLevels="4"

  SkipLinkText=""

  CssClass="s4-tn"/>

<SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource">

<Template_Controls>

<asp:SiteMapDataSource

  ShowStartingNode="False"

  SiteMapProvider="CustomTopNavProvider"

  id="topSiteMap"

  runat="server"

/>

</Template_Controls>

</SharePoint:DelegateControl>





basically we are setting the SiteMapProvider to the provider we added in the web.config that reads our custom site map file. We don't show the starting node, we remove an ID of the DelegateControl (may or may not be necessary) and then set the StaticDisplayLevels of the ASPMenu to 1 and the MaximumDynamicDisplayLevels to 4. S

Save masterpage, reload page and whamooo, it should work. If not, leave a comment and I'll try to help.

Expanding on this, if you created a web part that could read and update the sitemap file, then users would not necessarily need access to the 1033 folder to update navigation.

UPDATE: after some research, it doesn't seem possible to dynamically update the .sitemap file using a web part. I suggest putting a custom folder in the 1033 folder for navigation and share it out to those who need to be able to update it. It will need to be update on all front end web servers.

Monday, March 22, 2010

SQL Reporting Keep Header Rows Visible Repeat on New Page

This shouldn't be that difficult to figure out. But it is, so here is how to do it.

Select the first static member of the Tablix and set the property of RepeateOnNewPage to True and the KeepWithGroup property to After.

That's it.