Hacking Infopath Form Template Source Files To Update Broken Workflow Connections

What Causes Broken Workflow Connections

There are a few common causes of broken workflow connections in InfoPath forms that are tied to SharePoint workflows:

  • The workflow host list or library has been moved or deleted – If the SharePoint list or library that hosts the workflow associated with the InfoPath form has been renamed, moved to a different site, or deleted entirely, this will break the workflow connection.
  • Permissions changed on workflow host – If permissions or access to the workflow host list have been reduced, such as hiding the list from certain users, the workflow may fail for those users when they submit the InfoPath form.
  • Columns referenced in workflow deleted – SharePoint workflows often rely on columns in the host list or library to capture data, look up information, or trigger actions. If those columns get removed, the workflows can no longer function properly.

These issues lead to the infamous “The workflow could not update the item” or “The workflow operation failed” errors when submitting an InfoPath form tied to a SharePoint workflow. To fix these errors, we need to get into the back-end of the InfoPath form template and update the broken connections.

Locating the InfoPath Form Template Source Files

To update broken workflow connections from an InfoPath form template, you first need to locate the actual source files for the published form templates. This allows you to open up the backend data connections and workflows using the InfoPath designer interface. Here is how to find them:

Finding published form templates on SharePoint server

Published InfoPath form templates are stored within SharePoint in the Site Collection’s “Form Templates” library. To get started, navigate to this library in the Quick Launch or by clicking “Site Contents” from the top navigation bar. You can then review all published template files with a .XSN extension. The naming convention typically aligns to the Display Name given to the library form.

Downloading source (.xsn) files to your computer

Once you have located the correct .XSN template file related to your InfoPath form and associated workflow, you can download this source file directly to your local computer. This gives you a local copy you can then open up and edit using the InfoPath designer tool.

To download, hover over the template file and click the arrow that appears. Choose “Download a Copy”. This will save the .XSN file to your computer where you can then work on updating the broken connections.

Using InfoPath Designer to Update Data Connections

The key to resolving broken workflow issues in InfoPath lies in the InfoPath Designer interface. This tool allows you to modify the backend data connections, rules, and bindings within the form template. Here is the overall process to follow:

Opening .xsn file in InfoPath Designer

Locate the downloaded .XSN file on your computer and double click to launch it. This will automatically open up the InfoPath designer tool rather than the typical InfoPath Filler formatting. All aspects of the form template can then be reviewed and edited.

Navigating to Data Connections section

Within the main editing window, click on the “Data” tab along the top navigation. Next open up the “Data Connections” section along the left sidebar. This will show all data connections currently configured in the template, including the SharePoint Workflow connection.

Editing workflow host location or columns

Select the SharePoint Workflow connection and click the “Edit Connection Settings” option along the right. From here, you can modify the specific SharePoint site and list tied to the workflow, ensuring the accurate locations are set. Additionally, you can add/remove additional columns used by the workflow that may have been deleted or renamed.

Updating data connection settings

After editing the workflow connection details, make sure to click “Update Connection” to save all changes. Then click back through the hierarchy of editing windows in InfoPath to return to the main template editing screen. All data connection updates should now be saved.

Saving and publishing updated form template

With the workflow host location and column references fixed, you’re now ready to republish the modified InfoPath form template. Simply click “File” and choose “Publish”. Confirm all updates you want saved back to the original template file. This will output an updated .XSN source file you can then upload over the old version within SharePoint.

Updating Published Form Template in SharePoint

After modifying the InfoPath form template locally using the InfoPath Designer tool, you need to publish this updated .XSN file back into the SharePoint environment. This consists of three main steps:

Uploading edited .xsn template file to Forms library

In the SharePoint site, navigate back to the Site Collection’s Form Templates document library. Locate the existing .XSN file for the InfoPath form you have modified and delete it. Then upload or drag/drop your updated .XSN source file from your computer into the library to replace it.

Promoting updated template to production

By default, SharePoint will recognize the updated template file but may not immediately promote it to production. You can force this by editing the template file in the library. Open it up and click “Promote”. Confirm again to make your new version the primary production template.

Testing updated workflows with new template

The final, and perhaps most critical step, involves thoroughly testing your InfoPath form and associated SharePoint workflow using the updated template you published. Open up the InfoPath form entry and initiate a new workflow, confirming it submits successfully without any connection errors. Retest workflow functionality again across employee groups to ensure full resolution.

Example Code for Custom Workflow Host Location Update

In certain situations you may need to programmatically update the workflow host location configured within the InfoPath form template. This C# code snippet demonstrates how to dynamically generate a new workflow host URL and data connection information if the site structure changes:

C# code snippet to programatically update host location

private void UpdateWorkflowHostUrl() 
{
  String siteUrl = GetCurrentSharePointSiteUrl();  
  String listName = "Requests";
  
  String workflowHostUrl = String.Format("{0}/{1}", siteUrl, listName);
  
  thisXDocument.DataConnections["WorkflowHost"].ConnectionUri = workflowHostUrl;
  thisXDocument.DataConnections["WorkflowHost"].Update();
}

Explanation of code for updating workflow host URL

This code dynamically looks up the current SharePoint site URL where the workflow is hosted, stored in the “siteUrl” variable. It then takes the name of the workflow host list, defined in “listName”, and concatenates those values into a full URL string.

This new, updated URL is then passed into the InfoPath form’s DataConnections collection for the workflow host data source. This automatically points the workflow connection to the new host location. Finally, we call the Update() function to commit changes.

This allows dynamically keeping the workflow host pointed to the right site/list as needed if you migrate servers or change site layouts.

Troubleshooting Workflow Issues After Update

After going through all the steps to update broken workflow connections in an InfoPath template, you may still encounter issues with forms not submitting properly. Here are some things to check if the workflows are still failing:

Fixing remaining workflow errors

If you receive additional error messages after updating the InfoPath template, review the new messages closely to determine any new issues. You may find additional columns, stages, or libraries referenced that need to be corrected in the published form template or workflow design.

Handling permissions issues with service accounts

Check that the workflow and any related service accounts have proper permissions to access the workflow host list/library after changes. Occasionally permission changes can cause access denied errors – validate privileges on these accounts.

Resetting workflows to start working properly

One brute force trick is to manually delete any remaining stalled or failed workflow instances tied to your InfoPath form submissions. Once removed, initiate new form submissions to trigger brand new workflow instances using the fixed template. This effectively resets to engage the updated connections.

Leave a Reply

Your email address will not be published. Required fields are marked *