Tuesday, April 15, 2008

Cannot open Infopath attachments in Outlook 2007

I have built an InfoPath form and web enabled it. Users fill in the form in Internet Explorer and attach a file to it. When they press the “Save” button, a mail is sent to some receivers in Outlook. When they try to open the form, they get the following error:

Enlarged error:

I will try to translate the above error message here: “Infopath cannot open the following file c:\documents….” “The file is not a valid xml file”. “The form contains XML that cannot be parsed”. An invalid character was found in the content” and then it complains on the formatting of my attachment field which in this case is “fält2”.
After I press OK on the error message the form opens up as a normal mail, and not in InfoPath as expected:

As you can see, the mail attachment has been converted to an empty textbox!
The attachment is removed, because if I try to open the attached form.xml file I get the same error in InfoPath.
This happens to ALL types of files, except .txt files. If the user attach a .txt file and the form is opened in Outlook, it opens correctly and you can see that attached file:
I have this case at Microsoft right now, and will tell you the solution to this as soon as I get it.

Tuesday, April 8, 2008

Victory over SBS, YES!

Yes, today I have been fighting with a customers small business server - but I won!! What I did? The most dreaded - uninstalled WSS 2 on a SBS server and installed a fresh WSS 3 version. Everything went perfect until I wanted to give the new portal a hostname. Did not work. Every hostname or IP just redirected to the ugly Companyweb (even if I updated AAM in CA). Crazy. I ended up adding a new IP-address to the server and dedicate the new portal to that address instead. Removed all "old" shit in the IIS like old application STS-pools and stuff. In this order: added a new IP, added a new record in DNS pointing to that IP, changed the IIS web site to the new IP, added a new AAM-record in Central Administration. IISreset. Worked like a charm :) You just have to do things in the correct order, or everything will freak out. Now I just need a SSL cert and all is done. And me too...

Monday, April 7, 2008

Notepad ++

Get it today! A really really helpful extension of Notepad. Things you have been longing for :) The simplicity of Notepad but extended with functions like comparison (love it), intellisense (just select the code language you are using and it will color the tags...), line number etc etc. Lovely!! Get it here:

Happy coding :)

Change the "Sign in" text

If you want to change the "Sign in" link text on a Sharepoint page, then do this:

Open the beloved folder C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES

Open "Welcome.ascx" and go to the end of the file
Change the tag:

SharePoint:ApplicationPageLink runat="server" id="ExplicitLogin"
ApplicationPageFileName="Authenticate.aspx" AppendCurrentPageUrl=true
Text="<%$Resources:wss,login_pagetitle%>" style="display:none" Visible="false" />

to this:

SharePoint:ApplicationPageLink runat="server" id="ExplicitLogin"
ApplicationPageFileName="Authenticate.aspx" AppendCurrentPageUrl=true
Text="Your text here" style="display:none" Visible="false" />

No defined path - MySite

If you get an error message saying that MySite cannot be created due to a missing tag in the URL or error in the defined managed path, then you have to do this:

Open Central Administration
Application Management
Define managed paths
Add the path, like "personnel"

Stylesheets that are used in MOSS

I do a lot of CSS changes to my sites, I find that easier and quicker than to rebuild themes or site definitions and stuff.

MOSS 2007 uses the following css files:


When you create a WSS site, the following CSS files are used:




Anonymous access with Publishing portal

When you activate anonymous access on a site and you would like your anonymous users to be able to publish an item to a list, then you cannot use the template "Publishing portal". Why? Don't know! You must use the template "Team Site" for this to work! I noticed this when I had activated anonymous access but never got rid of the login-prompt! So.. I created a new site and used the template "TeamSite" and enabled anonymous access on it, then voila - an anonymous user was able to post an item to my list without being prompted with the login! Strange....

Remove the "Powered by..." in InfoPath forms

In this folder (the one and only.. right?) "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\INC" is a file that is called "ifsmain.css". This stylesheet file controls how a web form built by InfoPath is displayed. If you want to remove the logo "powered by InfoPath services" that is displayed in the bottom of every web form then write "display:none" or color the text tag to the same as your background color.

Create a new search scope

This is very useful. Say you have several web sites and you don't want to display the same search results on every web site - only the results relevant to the current site! Do this:

Open Central Administration
Open your SSP
Click on "Search settings" and then "Content sources".
There is a list of current content sources, there might just be only one:

Anyway, click "New content source"
Fill in the following fields like this
"Name of the Content Source" = your web site name
"Content Source Type"
"Start Addresses or Applications" (if you choose the Business Data option)
" Crawl Settings and Schedules"
I always enter the name of my content source to the name of the site, it makes it easy to know where it is applied :)
The start address is the URL of my site, for example http://mysite.se/

If the content source is a public site then you may not have to index the site so often. I usually run the Incremental Crawl each hour or so instead.
Now save your settings and perform a Full Crawl on your new Content Source.
When that is done, go back to "Search Settings" and select "View Scopes":

This page shows what scopes this SSP handles. Add a new scope and call it the same name as your content source, ie "mysite". Now, you have to add some rules to your scope:

Click on "Add rules" and add the following:

I checked the "Content Source" so that I could select my content source "mysite". Then I checked "Include" because I want all info on this site to be returned in the search results. Now you have to update your new scope.

Click on "Start update now" from the Search settings page.
When the update is ready, you have to associate the scope to your site. Go to Site Settings on your site, click on "Search Scopes" under "Site Collection Administration". Click on the "Search Dropdown" link:

Now all available scopes are shown including our new scope:

Select your new scope – wow! Uncheck the other scopes, we do not want them on this site.
Your list should now look like this:

Now try your site search. When I did this, other search results STILL showed up. To change this, click on "Edit page" and select "Modify shared webpart" on your search result page. There is a field called "Scope" and even if there is no list to select your scope from, you can simply write in the name of your scope, like "mysite".
Now when you perform a new search, only results from your site will be displayed!

Event id 7888 in Eventviewer

A while ago I got a lot of error messages in Event Viewer on our MOSS server. I found the following solution:

run stsadm -o sync -DeleteOldDatabases 0

and the message disappears.
What it does is enter the table "sitesynch" on the SQL server and deletes connections to any old Sharepoint config database that you may have on your server.

The entire message:

A runtime exception was detected. Details follow.
Message: A duplicate site ID 3b2fa192-1efb-4715-970f-2e550122faf0(
https://xxxx) was found. This might be caused by restoring a content database from one server farm into a different server farm without first removing the original database and then running stsadm -o preparetomove. If this is the cause, the stsadm -o preparetomove command can be used with the -OldContentDB command line option to resolve this issue.
Techinal Details:
Microsoft.Office.Server.UserProfiles.ProfileSynchronizationDuplicateSiteIDException: A duplicate site ID 3b2fa192-1efb-4715-970f-2e550122faf0(
https://xxx) was found. This might be caused by restoring a content database from one server farm into a different server farm without first removing the original database and then running stsadm -o preparetomove. If this is the cause, the stsadm -o preparetomove command can be used with the -OldContentDB command line option to resolve this issue.
at Microsoft.Office.Server.UserProfiles.ContentDBSynchronizer.RegisterSitesForSynch(Guid[] rgGuid, Int32 nGuids, Object dummy)
at Microsoft.Office.Server.UserProfiles.SynchCollection`2.FlushAdds()
at Microsoft.Office.Server.UserProfiles.SynchCollection`2.Add(T objAdd)
at Microsoft.Office.Server.UserProfiles.ContentDBSynchronizer.AddRemoveSites(String strFirstChangeToken, SPChangeToken lastChangeToken)
at Microsoft.Office.Server.UserProfiles.ContentDBSynchronizer.SynchContentDB()
at Microsoft.Office.Server.Diagnostics.FirstChanceHandler.ExceptionFilter(Boolean fRethrowException, TryBlock tryBlock, FilterBlock filter, CatchBlock catchBlock, FinallyBlock finallyBlock)

Install IFilter on MOSS

How to install the PDF iFilter so that pdf files are searchable (and given an icon too)

Download the latest Adobe PDF IFilter from http://www.adobe.com/support/downloads/detail.jsp?ftpID=2611
Stop the IIS service
Run the Adobe PDF IFilter Setup on your MOSS server
Copy the ICPDF.GIF file (search your server) to "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\Images"
Open "C:\Program Files\Common Files\Microsoft Shared\Web server extensions\12\Template\Xml\DOCICON.XML"
Add the following to the .pdf type:

Run iisreset
Add the .pdf file type in the following list:
Open Central Administration, Shared Services Administration (SSP), Search Settings and select File Type
Add the new filetype pdf
Perform a fullcrawl of your content source

Useful STSADM commands

path to STSADM is
cd C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN

stsadm -o addcontentdb -url URL [-databaseserver servername] –databasename databasename [-DatabaseUser username -DatabasePassword password] [-SiteWarning number] [-SiteMaximum number] [-SearchServer servername]

stsadm -o addcontentdb -url http://srv007:42464 -databasename Sharepoi1_SITE

stsadm.exe -o restore -url http://srv007:24003 -filename c:\backup\migrera-SRV005-ComSolut1_SITE.SPB

create a new site using a template in another language (in this case... surprise, Swedish!!)
stsadm.exe -o createweb -url http://server:port/sitename
-lcid 1053

export a site with version history and security remained
stsadm.exe -o export -url http://url/site -filename c:\backupsite\ds.bak -includeusersecurity -haltonfatalerror -versions 4

import a site with version history and security remained
stsadm.exe -o import -url http://url/site -filename c:\backupsite\ds.bak -includeusersecurity -haltonfatalerror -updateversions 1

Dropdown with URL in onchange

If you want to create a dropdown list with onchange event to dynamically go to selected URL then do this:

Use Sharepoint Designer
Insert Data View
Select Show Data
Select which field that should be displayed in the drop-down list
Insert Data
Change layout to “Drop-down view style”
Click OK
Change to Code view in Designer
Put the following code before the /head> tag:

script language="JavaScript">


Then find the following in your code
select name="ID" size="1"12
Change that to
select name="ID" size="1" onchange="FP_jumpMenu(this,'window',false)">

Then find
option style="display:{$GroupStyle}"
Change to
option style="display:{$GroupStyle}" value=”{@FieldWithURL}”>
where FieldWithURL is the link that you want to go to

Custom source in profile import

If you would like to be able to select which OU to import from in your Active Directory then select Custom Source in "Configure Profile Import" in the SSP settings. That will let you write your own custom source like the following example:

OU=NaBSolutions,OU=Hosting,DC=yourdomain, DC=se

The default setting is DC=yourdomain, DC=se so what you will do is to put the OU in front of the DC since it must be in a hierarchy.

Cool! So instead of importing 400 accounts from your AD you get the accounts that are relative to your site!

Create a content type for Word

I love content types in Sharepoint. I use them when I create new publishing pages, new templates, new columns and yeah that's it. So useful and powerful. Change in one place - update all others!

If you want to publish a Word template to a library you... that's right - create a new content type and associate your library with it. If you make any changes to your template, all libraries that use that template are.... updated!

Do this:
Site Actions, Site Settings, Modify All Site Settings
Click on ”Site content types” and ”Create”
Create a new with the name of your template, ie "Agreement"
Select ”Document Content Type” as Parent Type, and ”Document”
Put your content type in a new group with your company's name for example (this is so that you know which content types you have created and you will also find them easier)
Click OK (needed for any dummies :))
Click on ”Advanced settings” and select the template that should be associated with this content type by clicking on ”Upload new document template”
You don't have to mark it as readonly, but do select that it should be updated.
Open the document library where you want to use this new content type and do:
Click on ”Document library setttings” and select ”Advanced settings”
Activate ”Allow management of content types”
Click OK
On the middle of that page a new group is visible. Click on ”Add from existing site content types”
Select your group (your company name for example) and get your new content type
That was not so many steps.... :)
Now, when you look at your "New"-button in your library the new button "Agreement" should be visible! You can also metatag those templates with their own metatags, if you want to use several templates in the same library. Cool!

Content Deployment error

When I should activate Content Deployment on our Sharepoint server I got the following error message:
"Value does not fall within the expected range"
Oh I just love the error messages in Sharepoint, they are so informative :)

Ran the following commands instead:

Stsadm -o deactivatefeature -name deployment -url
Stsadm -o deactivatefeature -name migration -url
Stsadm -o activatefeature -name deployment -url
Stsadm -o activatefeature -name migration -url

Got the message
"Failed to find the XML file at location '12\Template\Features\migration\feature.
Opened the folder and saw that the folders "migration" and "deployment" were missing, but there was another called "Deployment Links" and "Migration Links". Copied those and renamed them to only "Deployment" and "Migration". Success! I was able to activate the new feature!

Deactivate the name.dll active x control

Websites built on SharePoint 2007 prompts you to install Microsoft's Name.dll ActiveX control on every page load of your SharePoint web site. Name.dll provides "presence" functionality, that is if you have Messenger it will display your online status. This is annoying, I think anyway :)

To remove the prompt on a site you have to do the following:

Go to the folder (the one and ONLY folder as a Sharepoint developer/administrator...)

"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS"

If you don't want this to affect all of your websites (it is a really useful function on your intranet for example) so create a new folder on your server and copy the contents of the "LAYOUTS" folder to a new folder. Let's ensure SharePoint will have permission to access the files. Through Explorer, open the properties for your newly created folder and under the security tab add the "WSS_WPG" account (the default Read & Execute, List, and Read permissions are enough) and let's add the WSS_ADMIN_WPG account with full permissions (see image below). In the IIS Manager Console, open the properties for the "_layouts" virtual directory (under the web site you want to modify) and change the local path directory to your newly created folder. Test your Web Site and make sure everything is working.

The ActiveX feature is in a script file called INIT.JS located in the \LAYOUTS\1033 folder.

Go to the function called EnsureIMNControl()
Comment out the ActiveXObject line:
//IMNControlObj=new ActiveXObject("Name.NameCtrl.1");

After applying any updates or service packs to SharePoint you'll probably want to reverse this customization and perform these steps again after the update to ensure your web site is running on the latest code.
function EnsureIMNControl()
if (!bIMNControlInited)
if (browseris.ie5up && browseris.win32)
//@if (@_jscript_version >=5)
//@ try
//@ {
//@ //IMNControlObj=new ActiveXObject("Name.NameCtrl.1");
//@ } catch(e)
//@ {
//@ };
if (IMNControlObj)
return IMNControlObj;

Hide items from users

You can hide some functions from users on a page in Sharepoint by adding the "security trimming control" - it's really useful. For example, the "Site Actions"-button should be hidden from anonymous users.

Put the following tag around the Site Action control:

Sharepoint:SPSecurityTrimmedControl runat="server" PermissionsString="BrowseDirectories">
[Site Actions content holder here]


This permission string used the "BrowseDirectories" which is a very low level of permission. You can also use "AddItems" and so on, to allow users that has EditItems to see the SiteAction button but hide it from those who can Add items.

Missing features

When you install the language templates I have discovered that many functions are missing. The solution is to compare the 1033 folder with the 1053 and copy the files that are missing to your new language folder.

For example the search function on WSS pages:

I had to copy the file search.js into the 1053 (which is for Swedish) folder, and magic - it's visible!

Script that hides the statusbar in the web browser


function hidestatus(){
window.status='Lises hemsida'
return true
if (document.layers)
document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)

Error message in InfoPath after MUI installation of swedish lang files for Office

After the installation of the MUI swedish language files on our Sharepoint server, the following error occurs:
if you have any multiline fields in your InfoPath forms, like RTF fields, you are no longer able to mail those forms!
Really strange error, I know - but my world is full of strange errors.... I am so sick of it. The entire message reads:

Reference to undeclared entity 'nbsp'. Line 85, position 6559.
System.Xml.XmlException: Reference to undeclared entity 'nbsp'. Line 85, position 6559.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.HandleGeneralEntityReference(String name, Boolean isInAttributeValue, Boolean pushFakeEntityIfNullResolver, Int32 entityStartLinePos)
at System.Xml.XmlTextReaderImpl.HandleEntityReference(Boolean isInAttributeValue, EntityExpandType expandType, Int32& charRefEndPos)
at System.Xml.XmlTextReaderImpl.ParseText(Int32& startPos, Int32& endPos, Int32& outOrChars)
at System.Xml.XmlTextReaderImpl.FinishPartialValue()
at System.Xml.XmlTextReaderImpl.get_Value()
at Microsoft.Office.InfoPath.Server.Xml.SafeXmlReader.get_Value()
at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
at System.Xml.XmlDocument.Load(XmlReader reader)
at Microsoft.Office.InfoPath.Server.Xml.SafeXmlDocument.Load(XmlReader reader)
at Microsoft.Office.InfoPath.Server.Xml.SafeXmlDocument.LoadXml(String xml)
at Microsoft.Office.InfoPath.Server.SolutionLifetime.DataAdapterEmail.GetViewHtml(XmlDocument input, String viewName, XsltContext xsltContext, Solution solution, Boolean cleanUpFormatting, String intro, String introSubmittedBy, ImageAttachmentHelper imageAttachmentHelper)
at Microsoft.Office.InfoPath.Server.SolutionLifetime.DataAdapterEmail.Execute(XPathNavigator input, String to, String cc, String bcc, String subject, String intro, String attachmentFileName, String viewName, Boolean sendAsInfoMail, EmailAttachmentType emailAttachmentType, XsltContext xsltContext, String xsnUrl)
at Microsoft.Office.InfoPath.Server.DocumentLifetime.DataAdapterEmail.ExecuteInternal(XPathNavigator input)
at Microsoft.Office.InfoPath.Server.DocumentLifetime.DataAdapterEmail.Execute()
at Microsoft.Office.InfoPath.Server.SolutionLifetime.RuleAction.EvaluateExpression(Document document, XPathNavigator currentTarget)
at Microsoft.Office.InfoPath.Server.SolutionLifetime.RulesRuleSet.<>c__DisplayClass7.b__4()
at Microsoft.Office.InfoPath.Server.SolutionLifetime.RulesRuleSet.EvaluateExpression(Document document, XPathNavigator targetNavigator)
at Microsoft.Office.InfoPath.Server.SolutionLifetime.ButtonFormCode.<>c__DisplayClass2.b__0()
at Microsoft.Office.InfoPath.Server.SolutionLifetime.ButtonFormCode.Click(Document document, XPathNavigator container)
at Microsoft.Office.InfoPath.Server.DocumentLifetime.EventClick.Play(Document document, BindingServices bindingServices, EventLogProcessor eventLogProcessor)
at Microsoft.Office.InfoPath.Server.DocumentLifetime.Event.PlayEvent(Document document, BindingServices bindingServices, EventLogProcessor eventLogProcessor)
at Microsoft.Office.InfoPath.Server.DocumentLifetime.EventLogProcessor.<>c__DisplayClass1.b__0()
at Microsoft.Office.InfoPath.Server.DocumentLifetime.EventLogProcessor.ExecuteLog(Int32 expectedEventLogID)
at Microsoft.Office.InfoPath.Server.DocumentLifetime.Document.<>c__DisplayClass6.b__3()
at Microsoft.Office.Server.Diagnostics.FirstChanceHandler.ExceptionFilter(Boolean fRethrowException, TryBlock tryBlock, FilterBlock filter, CatchBlock catchBlock, FinallyBlock finallyBlock)

And the simple solution to this error is to replace your multiline field and replace them with "common" plain text fields. And, tada, you are able to mail the form again!

"Save site as template" is missing... or?

Yes but it's available with a little trick :)

If you try to save a website as a template, you'll find out that there is no link to it in administration mode (web site settings). You must change the following in the URL and it will be available:
Change from this URL:
To this URL:
and you may save your website as a template!

Application pool id and w3wp

To find out which application pool runs a certain w3wp.exe process, use the command:
C:\WINDOWS\system32>cscript iisapp.vbs

Install IFilter on a single WSS 3.0 server

Install Ifilter for WSS3.0 on a single server using the built-in embedded SQL edition:

1) Download and install the latest Adobe Reader 8
2) Edit this registry key:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\Search\Applications\{GUID}\Gather\Search\Extensions\ExtensionList
Add a new string value with Name=(next sequential number available - usually 37 or 38) and set the Data=pdf
3) Check registry key:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\Search\Setup\Filters.
There should be a Key with Name=.pdfWithin the .pdf key, the following entries should be present:String Value with Name=Extension and Data=pdfBinary Value with Name=FileTypeBucket and Data=1 (0x00000001)String Value with Name=MimeTypes and Data=application/pdf
If the entries are not present, add them.
4) Check registry key:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\Search\Setup\ContentIndexCommon\Filters\Extension
There should be a Key with Name=.pdfand within the .pdf Key, there should be the following:Default with Data={AdobeReaderGUID}
If the entries are not present, add them.
5) Add the Installation directory of Adobe Reader 8 to the System Path:
System Properties (Windows Key + Pause/Break key) - Advanced Tab.Click Environment Variables buttonScroll down to Path in System Variables and click EditAppend "C:\Program Files\Adobe\Reader 8\Reader" (or whatever install path) to the end of the list.
6) Restart the WSS Search service:
net stop spsearch
net start spsearch

Sharepoint 2009

Found this about the new version of Sharepoint - 2009. Exciting news!!
I am hoping for better performance, extended functions, improved CMS and well, the list is long!
Seems like they are developing the offline function - or rather - I know they are since I was interviewed by a developer at Microsoft regarding my experiences of using offline. And they are totally bad. Groove may work fine but I am not so impressed by it, to be honest. You have to learn Groove, and when you save a file it is saved in a folder - it does not tell you where in your portal the file belongs. I have tried some third part products like Syntergy, and they work quite well - I really hope Microsoft develop their own builtin solution in the next version.

These are some features in Sharepoint 2009 to look forward to :)

* SharePoint v4 will be able to render a greater set of Office documents in an HTML environment
* Knowledge Management
* More rich reporting tools over Record Management
* More rich features such like
- Print features
- Scan Documents (Shipped with the box IFilters to support more search over content)
- More support for Shell Commands
- Object Model more extendible and rich with SOA models.
- Master Data Management (designed to manage common reference data for systems through an enterprise)
- Extremely improved UI en UX (Think Tafiti, Silverlight)
- Deliver improved search relevancy
- Include tighter integration of unified communications, unified identity, and unified policy/compliance/support across all apps and for all devices
- Improve SharePoint's offline capabilities.
- "14" will ONLY be released on a 64 bit platform. That is there will be no future 32 bit releases.
- Claims based authentication
- Better support on web 2.0
- Deeper unification of communications
- Content tagging/rating
- BI capabilities to business processes
- better management of complex documents and content
- a flexible storage solution for Digital Asset Management

Hide controls on a publishing page

When you build publishing pages in Sharepoint Designer you may want to hide some fields while it's in read mode. I usually want to hide fields like "Archive date", "Target group" and so on, and to do that you simply put them in an Edit panel. Now the fields are visible in edit mode, but hidden in read mode. That's really neat, since it's ugly to have a lot of fields when the page is in read mode. But I still want to be able to use the content of those "hidden" fields to sort the pages, or to filter information. Useful!