Blog Stats
  • Posts - 10
  • Articles - 5
  • Comments - 22
  • Trackbacks - 0

 

Unable to manage form templates

Just solved a problem, and wanted to document the solution.

Problem:

SharePoint MOSS 2007 Central Administrations site.  Select Application Management --> InfoPath Forms Services --> Manage form templates.

This runs the page _admin/ManageFormTemplates.aspx

Response is the ever-helpful SharePoint screen:  Error.  Unknown Error.

Thanks, guys.  How do I turn on custom errors in SharePoint?

And how do I get Manage form templates to work?

Disclaimer

`No warrantees, express or implied, are granted with this information.  Please note that this information is FREE and me being nice enough to give it to you does not mean that you should do anything with it, and that it won't do anything horrible to your systems.  Above all, I'm not liable for what you choose to do with it. 

As a matter of fact, THIS INFORMATION HAS THE CAPABILITY OF RUINING YOUR INFRASTRUCTURE AND COSTING YOU UNTOLD MAN-HOURS, MONEY, AND DOWNTIME.  APPROACH WITH CAUTION.

Your continued reading is evidence of your acceptance of this risk, and your agreement that I have nothing to do with whatever problems you might have.

Solution:

To get useful errors in MOSS is not as easily as .NET, but the answer is out there.  Here it is in an easier format.

Find the web.config for the site experiencing the issue (in this, case, the Central Administration site.)

If you're not sure where that is, IIS Manager --> <server> --> Web Sites --> Right-click <Web Site> --> Properties --> Home Directory tab --> Local Path.  Copy and paste that string into the address bar of Windows Explorer.

Edit web.config in a text editor (preferably Notepad).

Set <SafeMode ... CallStack="false" ...> to CallStack="true".

Set <customErrors mode="On" /> to mode="Off".  (This is the .NET way to turn on stack trace information.)  If this is a production system, you should set customErrors mode="RemoteOnly" and troubleshoot from the web server console.

Set <compilation batch="false" debug="false"> to <compilation batch="true" debug="true">

Save your file.  (Make sure the editor didn't add a .txt extension or something stupid.)

Now you'll get an error message that actually means something.

In my case, it returned the following error:

Object reference not set to an instance of an object.   at Microsoft.Office.InfoPath.Server.Administration.FormTemplate.SolutionDeploymentFailed()
   at Microsoft.Office.InfoPath.Server.Administration.FormTemplate.get_FormTemplateStatus()
   at Microsoft.Office.InfoPath.Server.ApplicationPages.FormTemplatePropertiesPage.GetStatusString(FormTemplate template)
   at Microsoft.Office.InfoPath.Server.ApplicationPages.ManageFormTemplatesPage.AddTemplateToTable(FormTemplate template, DataTable table, SPWeb web)
   at Microsoft.Office.InfoPath.Server.ApplicationPages.ManageFormTemplatesPage.FillDataTable(DataTable table)
   at Microsoft.Office.InfoPath.Server.ApplicationPages.GridViewPageBase.GridViewDataSourceView.FillDataTable(DataTable table, DataSourceSelectArguments selectArguments)
   at Microsoft.Office.InfoPath.Server.ApplicationPages.GridViewPageBase.GridViewDataSourceView.Select(DataSourceSelectArguments selectArguments)
   at Microsoft.SharePoint.WebControls.AdministrationDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments)
   at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
   at System.Web.UI.WebControls.DataBoundControl.PerformSelect()
   at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
   at System.Web.UI.WebControls.GridView.DataBind()
   at Microsoft.Office.InfoPath.Server.ApplicationPages.GridViewPageBase.RefreshDataGrid()
   at Microsoft.Office.InfoPath.Server.ApplicationPages.ManageFormTemplatesPage.OnPreRender(EventArgs e)
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Troubleshoot issues with Windows SharePoint Services.

 I tried a bunch of things, but nothing worked.  My partner (development-oriented) and I suspected that a database record in the list of published InfoPath forms had a null where it shouldn't be, but we couldn't figure out how to find the bad record.  (Where does SharePoint store the darn thing?)

Well, he wrote up a script which uses imbedded SharePoint code (installed dll's) to get at the forms record, since we never could find the actual record in the database manually.

WARNING!!!  This script is capable of deleting all of your installed InfoPath forms, as well as all associated workflows!!  Do not run it unless you understand what each line is doing!

Private Function GetFSService() As FormsService
        Dim Farm As SPFarm
        Dim FS As New FormsService
        Farm = SPFarm.Open("Data Source=<DataSource>;Initial Catalog=<SharePoint Config DB>;Integrated Security=True")

        Try
            FS = Farm.Servers.GetValue(Of FormsService)(FormsService.ServiceName)
            For Each frm As FormTemplate In FS.FormTemplates
                frm.FormTemplateStatus.ToString()
                'for each St as Microsoft.SharePoint.SPSite in farm.
                'frm.Delete()
                'Next
            Next
        Catch ex As Exception
            'ERROR
        End Try
    End Function

Ok, have you been warned enough?  See that remarked little frm.delete?  That tells the system to delete all your stuff.  Bad.  What my partner did was to unremark the delete command and run the script within VB Studio in debug mode, so he could step through it one line at a time.  When it found the first record, he told it to delete the record, then checked the site again.  Lucky for us, the record with the null field was the first one in the database.  After that was deleted, everything was sunshine, lollipops, and roses again.

So there you go.  I doubt you'll hit the same problem as I did; I didn't find any fellow victims on Google.  But the methodology for turning off the custom error is darn useful.  Thanks to Andrew Connell and Anders Rask.

-Tom Kretzmer


Feedback

# re: Unable to manage form templates

Gravatar Thanks Tom for posting this. This is very helpful..
I ran into exact same issue.

But can you please post the entire code instead of just the Function.

This function doesn't compile and run.. what all references do i have to add
12/12/2007 4:33 PM | Ankur

# re: Unable to manage form templates

Gravatar As I mentioned in the article, if you can't use this, you shouldn't run it; it'll delete all your form templates. You have to call the FormTemplate Class within the Microsoft.Office.InfoPath.Server.Administration namespace of microsoft.office.infopath.server.dll. It's not the kind of thing you just compile and run. Personally, I don't know how to actually do this; my partner came up with it. Try this link for additional info: http://msdn2.microsoft.com/en-us/library/microsoft.office.infopath.server.administration.formtemplate.aspx

Glad that you took the time to comment; hope this helps!

-Tom 12/14/2007 2:36 PM | Tom

# re: Unable to manage form templates

Gravatar Further information from my partner:

<quote>
You need to copy the code into a class in visual studio and run it in debug to step through the code to find the form template with the error then reposition the running code pointer to the delete statement to remove the form template causing the error.
</quote>

Hope that helps - all of my coding is done in Notepad.
12/14/2007 3:59 PM | Tom Kretzmer

# re: Unable to manage form templates

Gravatar I encountered the issue when the solution no longer exists in the farm (Operations-> Solution Management). See if you can see a solution matching your form there. If the report is deployed and the solution is removed, the ManageFormTemplates.aspx page blows up. Nice. What to do if you are in this boat?

What I did was:
1) Open the form in InfoPath design mode.
2) From the File menu, choose properties
3) Copy the form id
4) On the SharePoint server execute the following statement in a command window: stsadm -o removeformtemplate -formid <enter copied id here>

The response from the server was:
The form template has been successfully initiated for removal from the farm.

Tried to access the ManageFormTemplates.aspx page and all was right in the world.

This was not a fun error to track down at all... 2/28/2008 3:37 PM | Phil

# re: Unable to manage form templates

Gravatar Tom I really wanna thank you for this great article
I encountered same problem when i deleted the solution before the form template
I write windows application and add two references
1- C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI\Microsoft.SharePoint.dll
2- C:\Program Files\Microsoft Office Servers\12.0\Bin\Microsoft.Office.InfoPath.Server.dll
and here is the whole code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using Microsoft.Office.InfoPath.Server.Administration;

namespace ManageFormTemplatesFix
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SPFarm Farm = SPFarm.Local;
FormsService FS = new FormsService();
try
{
FS = Farm.Servers.GetValue<FormsService>(FormsService.ServiceName);
foreach (FormTemplate frm in FS.FormTemplates)
{
// here you get the form template whiich cause the problem by uncomment the line below and put breakpoint
//frm.FormTemplateStatus.ToString();
// then you put its name of your formTemplate instead of TempForm[2]and comment the abbove line
if (frm.DisplayName == "TempForm[2]")
{
frm.Delete();
}
}
}
catch (Exception ex)
{

MessageBox.Show(ex.Message);
}

}
}
}
3/3/2008 8:32 PM | Osama Naeem

# re: Unable to manage form templates

Gravatar Following Osama Naeem's C# solution - I am trying to run the program remotely, but am having SQL connection problems.

I am trying

"SPFarm Farm = SPFarm.Open("Data Source=MACHINENAME;Initial Catalog=MOSSSQL;User Id=DOMAIN\\admin;Password=#############");"

instead of the line

"SPFarm Farm = SPFarm.Local;"

What should the initial catalogue be? The Central Admin one or the SharePoint one? Connecting remotely do I need extra parameters in my connection string? I'm familiar with C# and Central Admin but not SQL and the guy I work with who knows is on holiday for a while!

Also, I followed Phil's advice and removed my form template using the command line but it did not fix the issue and my events log is full of errors saying

"Value cannot be null.
Parameter name: userName"

My debug error for ManageFormTemplates is exactly the same as Tom Kretzmer's

Any help I can get would be greately appreciated 4/4/2008 5:57 AM | John Speak

# re: Unable to manage form templates

Gravatar I was checking out the references to this piece, and found a good tidbit at http://www.infopathdev.com/forums/t/7571.aspx. Thank you, zeroecho.

This methodology uses the fact you still have access to the file system of the web server, even if you don't know the record number of the bad record, nor the fileid of the form. You may know the creation date of the bad record, in which case you can take advantage of the following:

stsadm.exe -o RemoveFormTemplate -filename <location>\<filename.xsn>

followed by stsadm.exe -o Execadmsvcjobs

zeroecho also had trouble with content types - not sure about that myself.

If you don't know where the location is, do a search on *.xsn of the SharePoint web server. The default is C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\<ID of feature>. The ID of the feature could look like a GUID, so look around.

Good luck. 5/28/2008 1:52 PM | Tom Kretzmer

# re: Unable to manage form templates

Gravatar I took the liberty to add a checkedListbox and a delete button to your fine solution.

Here's the Form1.cs:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using Microsoft.Office.InfoPath.Server.Administration;
using System.Linq;

namespace ManageFormInfopathFix
{
public partial class Form1 : Form
{
public int i = 0;
public SPFarm Farm = SPFarm.Local;
public FormsService FS = new FormsService();

public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
i++;
checkedListBox1.Items.Clear();
listBox1.Items.Clear();

try
{
i++;
FS = Farm.Servers.GetValue<FormsService>(FormsService.ServiceName);
i = 100;
foreach (FormTemplate frm in FS.FormTemplates)
{
string myItem = "";
string myStatus = "";
i++;
myItem = frm.DisplayName;
i++;
try
{
myStatus = frm.FormTemplateStatus.ToString();
}
catch
{
myStatus = "FAILED";
}
checkedListBox1.Items.Add(myItem);
listBox1.Items.Add(myStatus);
}
}
catch (Exception ex)
{

MessageBox.Show(ex.Message + " i=" + i.ToString());
}

}

private void button2_Click(object sender, EventArgs e)
{
textBox1.Text = "Delete started...";
for (int j = 0; j < checkedListBox1.CheckedItems.Count; j++)
{
textBox1.Text = textBox1.Text + "\r\n" + "ItemChecked: " + checkedListBox1.CheckedItems[j].ToString();
try
{
FS = Farm.Servers.GetValue<FormsService>(FormsService.ServiceName);
i = 200;
foreach (FormTemplate frm in FS.FormTemplates)
{
i++;
if (frm.DisplayName == checkedListBox1.CheckedItems[j].ToString())
{
textBox1.Text = textBox1.Text + "\r\n" + "Deleting " + frm.DisplayName;
frm.Delete();
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + " i=" + i.ToString());
}
}
textBox1.Text = textBox1.Text + "\r\n" + "Delete ended... ";
}

private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
listBox1.SelectedIndex = checkedListBox1.SelectedIndex;
}

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
checkedListBox1.SelectedIndex = listBox1.SelectedIndex;
}
}
}

You'll need a checkedListBox1 (Forms), a listBox1 (FormStatus) rigth next to it and a button1 (Start) and button2 (Delete) and a textBox1 (Status) with multiline and scrollbars enabled.

Enjoy, Jesper Simonsen 9/16/2008 7:23 AM | Jesper Simonsen

# re: Unable to manage form templates

Gravatar I've also just extended this further by using PowerShell to make the adjustment which is sometimes a lot easier than deploying an exe to a server if it's installed. Check it out.
http://wss.made4the.net/archive/2008/10/28/infopath-form-services-manage-form-templates-stuck-on-installing.aspx 10/28/2008 9:08 AM | Jeremy Thake

# re: Unable to manage form templates

Gravatar Jesper, thank you so much!

your code works fine! 4/4/2009 12:44 AM | Miguel Ballesteros

# re: Unable to manage form templates

Gravatar Just wanted to say thanks to those who have added additional information and pointers. :) 9/17/2009 7:17 AM | Tom Kretzmer

# Great News

Gravatar You are a very smart person! 10/11/2009 2:55 PM | Reebradub

Post a comment





 

 

 

Copyright © Tom Kretzmer