Nov 23, 2012

Infopath Filler 2007 managed code security problem

I had created an Infopath Filler 2007 form with managed code and domain level security to read an InputParameter from the query URL. I could publish the form to SharePoint 2010 Foundation (no Infopath Services) without a problem and the new document link would open Infopath from the browser, but the managed code wouldn't run. And no error message was shown. Previewing the form locally gave a message saying the code was not allowed.

 Step 1: Deactivate Internet Explorer Enhanced Security if you are working in Windows Server 2003 or 2008 and lower the security to minimum. Infopath takes its security directives from IE (

 After step 1, I got this error:

Request failed.
   at Microsoft.Office.InfoPath.MsxmlNavigator.IsValidNode(MsxmlNode test)
   at Microsoft.Office.InfoPath.MsxmlNavigator.MoveToFirstChild()
   at MS.Internal.Xml.XPath.XPathChildIterator.MoveNext()
   at MS.Internal.Xml.XPath.ChildrenQuery.Advance()
   at MS.Internal.Xml.XPath.ChildrenQuery.Advance()
   at MS.Internal.Xml.XPath.ChildrenQuery.Advance()
   at MS.Internal.Xml.XPath.XPathSelectionIterator.MoveNext()
   at System.Xml.XPath.XPathNavigator.SelectSingleNode(XPathExpression expression)
   at System.Xml.XPath.XPathNavigator.SelectSingleNode(String xpath, IXmlNamespaceResolver resolver)
   at ContactForm.FormCode.SubmitToList()
   at ContactForm.FormCode.cmdSubmit_Clicked(Object sender, ClickedEventArgs e)
   at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
   at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)

Step 2: Install SP3 for Office 2007 which updates the MSO core dll where the security problem lies.

Problem solved.

Sep 20, 2012

Change a web.config entry using SPWebConfigModification

At first glance, it's not completely obvious how to change an existing entry in the web.config using the SPWebConfigModification class. As it turns out, the key is in the Name attribute, which is actually an XPath expression. Most examples show how to add a new entry, so the Name and Value attributes are the same.

 Example of how to change an existing entry 

myModification.Name = "SafeControl[@Assembly='MyCustomAssembly'][@Namespace='MyCustomNamespace'][@TypeName='*'][@Safe='False']";

myModification.Value = "<SafeControl Assembly='MyCustomAssembly' Namespace='MyCustomNamespace' TypeName='*' Safe='True' />"; 

This will change an entry matching Name with Safe='False' to Safe='True'. If you wanted a more relaxed filter to match regardless of the Safe value, simply remove that part of the Name.

myModification.Name = "SafeControl[@Assembly='MyCustomAssembly'][@Namespace='MyCustomNamespace'][@TypeName='*']";

Aug 30, 2012

Debugging an SPTimerJob

Here's a checklist to run through if you're having problems debugging an SPTimerJob:

1. Make sure your Visual Studio debugger is attached to OWSTimer.exe
2. If you've updated the DLL for your SPTimerJob, you must restart the SharePoint Timer service.
3. Don't run the job using the "Run now" option in the Timer Definition page; instead program your job for a 1 minute interval and let the service run the job itself.

Aug 9, 2012

An exception occurred while enqueueing a message in the target queue. Error: 15404, State: 19. Could not obtain information about Windows NT group/user , error code 0x5

If you get this error with SharePoint and SQL Server filling up your SQL logs, try the following:

1. Check which user account is configured as the Service Account for your SQL Server instance.

2. Confirm in your Active Directory that the security object "NT Authority\Authenticated Users" have Read permission on your service account.  
  a.  Open  "Active Directory Users & Computers" on a Windows Server with admin permissions
  b. Active "Advanced features" in the View menu
  c. Right click the service user account and choose Properties
  d. Go to the Security tab and click on "Authenticated users" (If it doesn't exist, add it)
3. If the account is NTAuthority\NetworkService, change it to a regular domain account "yourdomain\yoursqlserviceuser" and restart the SQL Server service

4. Change the service account back to NTAuthority\NetworkService and restart the SQL Server service

5. Check if the error still appears.

Important:  The best practice is to use a regular domain account as the service account for SQL Server to avoid problems such as SQL backups across networks.

Aug 2, 2012

Running child activities in a custom SharePoint Designer activity

I ran into the simple question of how to run child activities I had dragged into my custom SequenceActivity.  I naively assumed they would run automatically but that's not the case.

1. Drag and drop activities into your custom activity (Sharepoint or standard WWF activities)
2. In the Execute method you override, call the context.ExecuteActivity method on each child activity in the EnabledActivities collection.
3. Bind to at least one close event for a child activity in order to be able to close the parent activity.
4. In the Execute method, set the context.ExecutionStatus to Running.

There are more details in the example from MSDN:

Aug 1, 2012

Output parameter in a custom Sharepoint Designer activity

If you're having trouble with an output parameter in a custom SharePoint Designer activity, check the following:

  • DesignerType="ParameterNames" in the FieldBind element in the .actions file
  • Direction="Out" in the Parameter element in the .actions file
And when you're sure everything is correct and your activity shows up in the SPD menu but doesn't do anything upon insertion, clear your SPD DLL cache:

In Windows 7, the path to the WebSiteCache folder is "C:\Users\yourUserName\AppData\Local\Microsoft\WebsiteCache"

Jul 24, 2012

The addDays function isn't working in Infopath

In certain cases, Infopath won't recognize the addDays function.  You simply need to specify the namespace as follows:

xdDate:addDays(today() , 90)

Jul 18, 2012

SharePoint site template error: The template you have chosen is invalid or cannot be found.

I spent hours reloading and changing names for a site template until found the root problem for this:  conflicting Template Id's in the web_template.xml files.

Basically, I had several site definition templates with the same Template Id.  So be sure to use unique template Id's and change the ones that Visual Studio 2010 generates for you.

Jul 5, 2012

Infopath formula errors using eval function

All the credit for this goes to:

Here's the problem I came across using the eval function on repeating groups:

  1.  You have a repeating group in Infopath 2010.  I haven't tried this in Infopath 2007
  2. An eval formula of the form:  eval( parentRepeatingGroup, 'concat(my:childElement,"abc")')  or something similar to
  3. The previous formula gives an error that the namespace 'my' doesn't exist
Solution:  Delete the formula, save and close the form and reopen it in Infopath.

Jun 28, 2012

How to change SharePoint 2010 service account passwords

Assuming you aren't using the automatic password changing feature of SharePoint 2010 and have already changed the account password in Active Directory.

Open the Sharepoint adminstrator powershell:

  1. $secure =  read-host -assecurestring
  2. Input password when prompted
  3. Set-SPManagedAccount -Identity domain\sp_farm -ExistingPassword $secure

Jun 27, 2012

Simple XSL file for an XSLT List View Webpart in SharePoint 2010

Here's the contents of a simple XSL file to apply to almost any XSLT List View webpart.  Of course you'll probably want to change a few fields and the layout, but it's much simpler than editing the entire XSLT view from Sharepoint Designer.

<xsl:stylesheet version="1.0" exclude-result-prefixes="x d xsl ddwrt" xmlns:x="" xmlns:d="" xmlns:xsl="" xmlns:ddwrt="">
<xsl:template match="/">
<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row" />
<xsl:for-each select="$Rows">
<xsl:value-of select="@Title" />

May 24, 2012

SharePoint 2010 custom CSS won't apply the theme colors

After playing with a custom CSS which wouldn't apply the colors defined in the theme, I came upon this post ( which laid out the criteria for a working themable CSS:

1. Properly formed CSS entries:
         /* [ReplaceColor(themeColor:"Dark2")] */ background-color:#ffffff;
2. Correctly located CSS file:
        /Style Library/1033/Themable/custom.css
       /Style Library/Themable/custom.css. 
       No other nesting will work.
3. Include CSS with a CSSRegistration control , not AlternateCSSUrl or CSSLink
4. Reapply the theme to calculate the themed CSS version

May 16, 2012

Simple visual guide to SharePoint 2010 themes

The most important colors are:

Dark 1
Light 1
Dark 2
Light 2

Here's a quick visual guide to how these colors affect the main page and navigation elements: