New sample project for SP2010 Word Automation: UI

0 comments

I’ve just published a second sample solution for the SP2010 Word Automation project on CodePlex. This solution will add a button to the Ribbon when browsing document libraries:

Ribbon button

When the button is clicked a modal Dialog is shown that will allow the user to specify the options used for conversion:

Modal Dialog

When the Ok button is clicked the selected files will be added to a conversion job and the job will be started.

The dialog is launched by some javascript that is specified in the CommandUIHandler section of the ribbon button definition.

<CommandUIHandler
Command="SP2010WA_Convert_Button"
CommandAction="javascript:function convertDocument() {
Sys.loadScripts(['/_layouts/SP2010WordAutomation.UI/SP2010WordAutomation.UI.js'], function() {
SP2010WordAutomation.UI.ConvertDocument();
});
}
convertDocument();"
EnabledScript="javascript:function oneOrMoreEnable() {
var items = SP.ListOperation.Selection.getSelectedItems();
var ci = CountDictionary(items);
return (ci > 0);
}
oneOrMoreEnable();" />

I’ve decided to use the beta version of the ASP.Net 4.0 AJAX client library to load the required scriptfile when it is actually needed. While this is not completely necessary in this case, because the amount of script in there is quite little, it could provide a speedboost because the browser won’t load and interpret the script when the page loads.

The definition also contains some script to enable the button only when one or more files are selected.

The following lists the script that is loaded and called when the button is clicked:

Type.registerNamespace("SP2010WordAutomation.UI");

SP2010WordAutomation.UI.ConvertDocument = function () {
var items = SP.ListOperation.Selection.getSelectedItems();
var selectedItems = '';
var k;

for (k in items) {
selectedItems += '|' + items[k].id;
}

var options = {
url: '/_layouts/SP2010WordAutomation.UI/ConvertDocument.aspx?items=' + selectedItems + '&source=' + SP.ListOperation.Selection.getSelectedList(),
title: 'Convert Documents',
allowMaximize: false,
showClose: true,
width: 600,
height: 480,
dialogReturnValueCallback: SP2010WordAutomation.UI.ConvertCallback
};

SP.UI.ModalDialog.showModalDialog(options);
}

SP2010WordAutomation.UI.ConvertCallback = function(result, target) {
SP.UI.Notify.addNotification(target, false);

SP.UI.ModalDialog.RefreshPage(result);
}

First I use the Type.registerNamespace method that is provided by the standard SharePoint scriptlibrary to make sure I don’t override other methods with the same names.

In the ConvertDocument function we then launch a SharePoint dialog that will load an ApplicationPage which provides the user with the options they can choose. The ConvertCallback function which is called when the dialog passes a result will add a notification message to the main screen.

To see how this mechanism can be used, please refer to this post by Vesa Juvonen

Tagged , , , | Leave a comment

2 new worflow activities added to SP2010 Word Automation

0 comments

I’ve added two new worfklow activities, Convert Folder and Convert Library, to the SP2010 Word Automation project on CodePlex.

Because you can’t associate workflows created with SharePoint designer to libraries or folders, these actions won’t use the current item from the context, so you need to specify the input and output library or folder by url. To use the activities you can run the workflow on a other item or document. The activities locate the libraries or folders relative to the current web, so you don’t have to specify a full url:

Convert Library Activity

Convert Folder Activity

You can download the latest release and source code from the CodePlex project site

Tagged , , , | Leave a comment

SP2010 Installation – Error creating configuration database

0 comments

When I tried to install the new RC of SharePoint 2010 on my machine, I got an “Error creating configuration database” message. When I went to the installation log I found a “User cannot be found” error. The cause was that the configuration wizard could not find the AD controller, which was easily solved by opening a VPN connection as I was working from home.

Tagged , | Leave a comment

CodePlex project for Word Automation Services

0 comments

I’ve just published the first release for a CodePlex project I started to provide sample projects / solutions for using the Word Automation Services in SharePoint 2010.

Word Automation Services allow you to convert document to and from different formats.

File formats the service can read:

  • Office Open XML (DOCX, DOCM, DOTX, DOTM)
  • Word 97-2003 Document (DOC) and Word 97-2003 Template (DOT)
  • Rich Text Format (RTF)
  • Single File Web Page (MHTML)
  • HTML
  • Word 2003 XML
  • Word 2007/2010 XML

File formats the service can write:

  • PDF
  • XPS
  • Office Open XML (DOCX, DOCM)
  • Word 97-2003 Document (DOC)
  • Rich Text Format (RTF)
  • Single File Web Page (MHTML)
  • Word 2007/2010 XML

(source)

As far as I’ve found out, there are no UI features available out-of-the-box to use these services, so I’ve decided to create some. The first one is a custom workflow action you can use in SharePoint Designer to convert a document to many of the supported
formats.

In the workflow designer you can add the “Convert Document” action:

Workflow Actions

The action is inserted into the workflow step where you can specify the url of the output file, select the output format and save options and select a variable for storing the conversion job id (which you can use later to retrieve the status, as the job runs asynchronous):

Convert document action

Save Behaviour

The job id is also logged into the Workflo w History Log (the second entry is from a second workflow action that logs the returned conversion job id variable):

image

After the job has run, which can take up to a few minutes (depending on the word automation services settings), the converted document appears in the library:

image

The custom workflow action is one of the first features for Word Automation in SharePoint 2010 I’ve planned to release. Other features will be a Ribbon and Item context menu extension and more Workflow actions.

Let me know if you have any suggestions for improvement or other functionality you would like to see.

Tagged , , , | Leave a comment

Force Visual Studio 2010 to add a SafeControl Entry

0 comments

When you create a project in Visual Studio 2010 on one of the SharePoint project templates it will take care of all the packaging for you.

But when I was working on a project with custom workflow actions, the SafeControl entry that is needed for making it work was not added to the generated manifest.xml file.

Fortunately the package designer allows you to modify the template file it uses for generating this file. So open up the package designer, switch to the “Manifest” tab and add the assembly reference in the template yourself, but this time, include the SafeControl entry:

image

You can safely use the SharePoint project tokens in there as well, but only for the SafeControl entry. When you put it into the Assembly entry, the package generator won’t understand it and will add another assembly reference for the project output:

image

Tagged , , | Leave a comment

Getting Custom Workflow Activities into SharePoint Designer 2010

1 comments

Developing a custom workflow activity for SharePoint 2010 doesn’t differ that much from developing one for the MOSS 2007 platform. So by following the different articles on that you will be able to create one with ease.

SharePoint 2010 still uses the same mechanism with an .ACTIONS file and adding an “authorizedType” element to your web.config. I was unsuccessful however in getting the activity to show up in SharePoint Designer 2010.

After adding a “SafeControl” entry to the web.config the activity did show up. As far as I can see this is the only thing different to the steps you have to take in MOSS 2007.

Tagged , , , | 1 Comment

Issues deploying FAST Search Server 2010 Beta

0 comments

I just had a tough time deploy FAST Search Server 2010 Beta on a new SharePoint 2010 farm. Upon searching the internet it looked like I had the same issue as loads of other people, a not complete/wrong installation guide. But even after reviewing the posts in this thread and reading the post from Manfred Berry, I was unsuccessful in getting FAST to work.

Until I dove into the logs on the FAST server, which is something I always postpone due to the overload of information in there. I found an error mentioning “Unrecognized attribute ‘allowInsecureTransport’”, caused by the dreaded WCF issue that needs the same hotfix as metioned here. So not only install the hotfix on your SharePoint servers but also on your FAST servers, which seems kind of logical now I think of that.

Tagged , , | Leave a comment

InfoPath Form Template stays in “installing” state

0 comments

When I was testing to deploy a solution containing some form templates I got an error. Not very strange, because I was testing it.

The main downside though was one of the templates remained in the installing state. Apparently the easiest way to remove this template is by using some custom code, in this case I just used a console application within my dev box:


static void Main(string[] args)
{
FormsService fs = SPFarm.Local.Services.GetValue("");

foreach (FormTemplate ft in fs.FormTemplates)
{
if (ft.Name.Contains("Blackberry"))
{
ft.Delete();
}
}
}
Tagged , | Leave a comment

Provisioning a Document Set

0 comments

In this post I’ll show you how to create a project in Visual Studio 2010 with the new SharePoint project and item templates to provision a Document Set from a feature.

DISCLAIMER: The examples are build on and tested against a Beta 1 build of SharePoint 2010 and a Beta 1 build of Visual Studio 2010, so there is no guarantee this will work on later versions or even on the Beta 1 build you’re running.

A Document Set is basically a content type just like all the others you can find in SharePoint, it derives from the Folder content type. So the steps you need to take to provision a Document Set content type are not that different as well.

We’ll start out by creating an empty SharePoint project in Visual Studio 2010 and work from there.

First we’ll add a Content Type item to the project. In the elements.xml file we place the following content:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ContentType ID="0x0120D520002228EBDE71841343B23171CE351F7D39" Name="Test Doc Set" Group="Document Set Content Types" Version="2" ProgId="SharePoint.DocumentSet">
<Folder TargetName="_cts/Test Doc Set" />
<FieldRefs>
<FieldRef ID="{038d1503-4629-40f6-adaf-b47d1ab2d4fe}" Name="Company" />
</FieldRefs>
<XmlDocuments>
<XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/events">
<spe:Receivers xmlns:spe="http://schemas.microsoft.com/sharepoint/events">
<Receiver>
<Name>DocumentSet ItemUpdated</Name>
<Synchronization>Synchronous</Synchronization>
<Type>10002</Type>
<SequenceNumber>100</SequenceNumber>
<Assembly>Microsoft.Office.DocumentManagement, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<Class>Microsoft.Office.DocumentManagement.DocumentSets.DocumentSetEventReceiver</Class>
<Data />
<Filter />
</Receiver>
<Receiver>
<Name>DocumentSet ItemAdded</Name>
<Synchronization>Synchronous</Synchronization>
<Type>10001</Type>
<SequenceNumber>100</SequenceNumber>
<Assembly>Microsoft.Office.DocumentManagement, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<Class>Microsoft.Office.DocumentManagement.DocumentSets.DocumentSetItemsEventReceiver</Class>
<Data />
<Filter />
</Receiver>
</spe:Receivers>
</XmlDocument>
<XmlDocument NamespaceURI="http://schemas.microsoft.com/office/documentsets/allowedcontenttypes">
<act:AllowedContentTypes xmlns:act="http://schemas.microsoft.com/office/documentsets/allowedcontenttypes" LastModified="11/4/2009 3:30:17 PM">
<AllowedContentType id="0x0101" />
</act:AllowedContentTypes>
</XmlDocument>
<XmlDocument NamespaceURI="http://schemas.microsoft.com/office/documentsets/sharedfields">
<sf:SharedFields xmlns:sf="http://schemas.microsoft.com/office/documentsets/sharedfields" LastModified="11/4/2009 3:31:50 PM">
<SharedField id="cbb92da4-fd46-4c7d-af6c-3128c2a5576e" />
<SharedField id="038d1503-4629-40f6-adaf-b47d1ab2d4fe" />
</sf:SharedFields>
</XmlDocument>
<XmlDocument NamespaceURI="http://schemas.microsoft.com/office/documentsets/welcomepagefields">
<wpf:AllowedContentTypes xmlns:wpf="http://schemas.microsoft.com/office/documentsets/welcomepagefields" LastModified="11/4/2009 3:31:50 PM">
<WelcomePageField id="038d1503-4629-40f6-adaf-b47d1ab2d4fe" />
</wpf:AllowedContentTypes>
</XmlDocument>
<XmlDocument NamespaceURI="http://schemas.microsoft.com/office/documentsets/defaultdocuments">
<dd:DefaultDocuments xmlns:dd="http://schemas.microsoft.com/office/documentsets/defaultdocuments" LastModified="11/5/2009 8:39:24 AM" AddSetName="True">
<DefaultDocument name="Enterprise Content Management.docx" idContentType="0x0101" />
<DefaultDocument name="Extending Search.docx" idContentType="0x0101" />
</dd:DefaultDocuments>
</XmlDocument>
<XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
<FormTemplates xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
<Display>DocSetDisplayForm</Display>
<Edit>ListForm</Edit>
<New>DocSetDisplayForm</New>
</FormTemplates>
</XmlDocument>
<XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url">
<FormUrls xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url">
<New>_layouts/NewDocSet.aspx</New>
</FormUrls>
</XmlDocument>
</XmlDocuments>
</ContentType>
</Elements>

As you can see, the basics are the same as for any content type. The main difference is in all the XmlDocument elements in there:

  • Some event handlers are hooked up to make sure the metadata gets pushed down into the child documents (plus some other stuff)
  • The content types that users are allowed to add to the set are specified
  • We specify which fields are shared between the documents the set contains
  • The fields that are shown on the welcome page are defined as well
  • We then specify if there’s default content to add when a new Document Set is created

After we’ve created the basic plumbing for the Document Set content type, we’ll need to make sure that the files that are required are created in the right place as well. In order to accomplish this we’ll add a SharePoint Module item to the solution. This module will create the welcome page and default content in the right location in the site collection. The element.xml file will contain the following content:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="_ctsTest Doc Set_" HyperlinkBaseUrl="http://moss.contoso.com/sites/docsettest" Path="WelcomePages\Files\_cts\Test Doc Set" Url="_cts/Test Doc Set">
<File Url="docsethomepage.aspx" Path="docsethomepage.aspx">
<AllUsersWebPart WebPartOrder="0" WebPartZoneID="WebPartZone_TopLeft" ID="g_ae6da3d4_9233_45d6_b9fd_6300815e16c6">
<![CDATA[Content omitted]]>
</AllUsersWebPart>
<AllUsersWebPart WebPartOrder="0" WebPartZoneID="WebPartZone_CenterMain" ID="g_d8062545_cc87_4e82_9c55_cae80486ffea">
<![CDATA[Content omitted]]>
</AllUsersWebPart>
<AllUsersWebPart WebPartOrder="0" WebPartZoneID="WebPartZone_Top" ID="g_651be1ba_c8bb_4d29_87b0_87c769cd5179">
<![CDATA[Content omitted]]>
</AllUsersWebPart>
</File>
<File Path="Enterprise Content Management.docx" Url="Enterprise Content Management.docx" />
<File Path="Extending Search.docx" Url="Extending Search.docx" />
</Module>
</Elements>

We see that the page layout for the document set homepage is created in the _cts folder for the content type. The web parts that are placed on the page are configured here as well, so any modifications and additions will be used on the welcome page of all document sets based in this content type. Also the two documents for the default content are placed in the corresponding _cts folder in the site collection.

The final Visual Studio solution will look like this:

image

After deploying the solution and activating the feature, which is very easy to do with the new SharePoint stuff in Visual Studio (just press ctrl + f5), we can see that the _cts folder will be created in the site collection:

image

After we add the content type to a document library and create a new item based on the content type we’ll be presented with the following:

image

You can download the sample solution here: DocSetProvisioning.zip (62,88 KB)

DISCLAIMER: This hasn’t been properly tested, so there’s is no guarantee it will work. If it f***s up your farm, the most you can expect as support from me, is an email wishing you good luck with restoring it.

Tagged , , | Leave a comment