Monday, July 27, 2009

InfoPath Property Promotion

 

When working with InfoPath Forms Services, the properties I was choosing to promote from the form were not appearing in the target list. It turned out that SharePoint was creating the required fields correctly as Site Columns, but they were not being added to the list.

Manually adding the Site Columns to the target list caused the properties to be promoted correctly when the form was submitted.

Tuesday, July 14, 2009

The template you have chosen is invalid or cannot be found. – SharePoint STP Fix-up

Copy the STP and rename as CAB
Extract the manifest file
Run the FeaturesChecker (code below) application to remove the missing refs..
Remove the offending features from the manifest
Use Cab File Maker (freely available) to rebuild the cab and rename to STP

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.SharePoint;
using System.Collections;
using System.Xml;
using System.Diagnostics;

namespace FeaturesChecker
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
List<string> siteFeatures = new List<string>();

using (SPSite bob = new SPSite("http://localhost/sites/bob%22))
{
foreach (SPFeature currentFeature in bob.Features)
{
ListViewItem newItem = listView1.Items.Add(currentFeature.DefinitionId.ToString());
//newItem.SubItems[0].Text = currentFeature.Definition.DisplayName;
siteFeatures.Add(currentFeature.DefinitionId.ToString());
}

using (SPWeb rootWeb = bob.OpenWeb())
{
foreach (SPFeature webFeature in rootWeb.Features)
{
siteFeatures.Add(webFeature.DefinitionId.ToString());
}
}
}

List<string> manifestFeatures = new List<string>();

XmlDocument manifest = new XmlDocument();
manifest.Load(@"C:\Customers\Bob\upf2\manifest.xml");
try
{
XmlNode manifestSiteFeatures = manifest.SelectSingleNode("Web/SiteFeatures");
foreach (XmlNode featureNode in manifestSiteFeatures.ChildNodes)
{
manifestFeatures.Add(featureNode.Attributes["ID"].InnerText);

}
}
catch (Exception noSiteFeatures)
{
Trace.Write("No Site Features");
}

XmlNode manifestWebFeatures = manifest.SelectSingleNode("Web/WebFeatures");
foreach (XmlNode webfeatureNode in manifestWebFeatures.ChildNodes)
{
manifestFeatures.Add(webfeatureNode.Attributes["ID"].InnerText);

}

listView1.Items.Clear();
int numMissing = 0;
foreach (string currentFeature in manifestFeatures)
{
if (!siteFeatures.Contains(currentFeature))
{
ListViewItem newItem = listView1.Items.Add(currentFeature);
textBox1.Text += currentFeature + "\r\n";
numMissing++;
}
}
MessageBox.Show(numMissing.ToString());
}
}
}