InfoPath DisplayName is Empty When Using UserName()

You created an InfoPath form, then added a text box to show the current users display name. Safe to assume you populated the text box using a rule and a set field value action. In the set field action, your Xpath might look like this:

xdXDocument:GetDOM(“My Data Connection”)/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Employee_x0020_Name_x0020_2/pc:Person/pc:DisplayName[../../../d:Title = concat(“DOMAIN\”, xdUser:get-UserName())]

In my case, when the user accessed userName(), it was returning a value other than what is in Active Directory. UserName() would return Jdoe but Active Directory had the user listed as jdoe. This caused the text box to be empty in my form.

Look at the local user account on their machine.

http://www.thewindowsclub.com/user-account-name-change

Find all Lists and Libraries Where InfoPath is Used

Recently had the need to find and update most every InfoPath form in a production farm. This, mixed with the future demise of InfoPath, prompted the need to find or write a script. The below script will traverse every list and library in a given web app. The script can be easily modified to include every web app in a farm.

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) 
{
                Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}

$fileName = "C:\xsn-" + $(Get-Date -Format "yyyyMMddHHmmss") + ".csv"

$webApp = Get-SPWebApplication "http://webApp.sharepointed.com" 
"Title `t URL `t Type" | out-file $fileName

$(foreach($siteColl in $webApp.Sites)
{
                foreach($web in $siteColl.AllWebs)
                {
                foreach($list in $web.Lists) {                        
                
                                if ($list.BaseType -eq "DocumentLibrary" -and $list.BaseTemplate -eq "XMLForm"){
                                                "$($list.title) `t $($list.parentweb.url)$($list.DefaultViewUrl) `t Library" | out-file $fileName -Append 
                                                                
                                                
                                }elseif ($list.ContentTypes[0].ResourceFolder.Properties["_ipfs_infopathenabled"]){
                                
                                                "$($list.title) `t $($list.ParentWeb.URL)$($list.DefaultViewUrl) `t List" | out-file $fileName -Append
                                                
                                                }
												else{
												$check = 0
								foreach($c in $list.ContentTypes) {
												if($c.DocumentTemplateUrl.ToString().EndsWith("xsn") -eq $true)
												{
													$check++			
												}
												}
												if($check -gt 0)
												{
													"$($list.title) `t $($list.ParentWeb.URL)$($list.DefaultViewUrl) `t List" | out-file $fileName -Append
												}
												}
												}}})

HTMLCHECKERLib.XMLPProcessorClass The form template failed to load

Lists that use InfoPath for the display and edit forms were randomly producing errors. It was randomly happening because, one of the WFE servers in the farm was out of sync.

To test, I logged into each WFE, then tried to display the list forms. Testing worked on one box but failed on the other.

From the WFE that was not displaying the forms, I ran the following command.

From the start menu, locate the Command Prompt icon, right click on it, then click on Run as administrator. One the command window opens, paste in the command below.

regsvr32 “C:\Program Files\Common Files\Microsoft Shared\OFFICE14\htmlchkr.dll”

This will not cause an IISreset.

Couple of the errors in the log.

10/18/2013 09:05:28.16 w3wp.exe (SPW2:0x46DC) 0x2D30 InfoPath Forms Services Maintenance 82fv Critical The form template failed to load. (User: domain\user, Form Name: Template, IP: , Request: http://sharepointed.com/site/Lists/listname/blah.aspx, Form ID: urn:schemas-microsoft-com:office:infopath:list:-AutoGen-2012-11-28T21:23:23:720Z, Type: InvalidCastException, Exception Message: Unable to cast COM object of type ‘HTMLCHECKERLib.XMLPProcessorClass’ to interface type ‘HTMLCHECKERLib.IHTMLtoXHTML’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{A260B372-BC78-441B-8764-D0B83F4004F4}’ failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).) 9130d182-80de-4da7-96d6-b2a566aea3e7
• 10/18/2013 09:05:28.18 w3wp.exe (SPW2:0x46DC) 0x2D30 InfoPath Forms Services Runtime 8gec Exception Unhandled exception when rendering form System.InvalidCastException: Unable to cast COM object of type ‘HTMLCHECKERLib.XMLPProcessorClass’ to interface type ‘HTMLCHECKERLib.IHTMLtoXHTML’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{A260B372-BC78-441B-8764-D0B83F4004F4}’ failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)). at HTMLCHECKERLib.XMLPProcessorClass.Convert(String bstrHTML) at Microsoft.Office.InfoPath.Server.DocumentLifetime.EventRichTextChange.HtmlToCleanXHtml(String html, Boolean makeDomCompatible) at Microsoft.Office.InfoPath.Server.SolutionLifetime.ItemFieldConnectorRichText.WriteValueNode(ListField fieldInformation, XmlWriter resultWriter, Object value) at Microsoft.Office.InfoPath.Server.SolutionLifetime.ItemFieldConnectorRichText.WritePropertyFromItem(Context context, ResultListItem listItem, XmlWriter resultWriter, ListField fieldInformation, String itemFieldsNamespacePrefix, String itemFieldsNamespace) at Microsoft.Office.InfoPath.Server.SolutionLifetime.DataAdapterListDataProvider.PopulateXmlForMultipleItems(Context context, ResultListItemIterator listItems, Dictionary`2 existingFields, Int64& auxDomSize) at Microsoft.Office.InfoPath.Server.SolutionLifetime.DataAdapterListDataProvider.PopulateXmlForSingleItem(SPListItem listItem, SPListItemVersion currentVersion, XPathNavigator resultFields, Dictionary`2 existingFields, Document document, Int64& auxDomSize) at Microsoft.Office.InfoPath.Server.SolutionLifetime.DataAdapterListDataProvider.LocalListItemQuery(SPContentTypeId contentTypeId, Document document, XPathNavigator resultFields, Boolean& needRegenerateChoice, Dictionary`2& existingFields, Int64& auxDomSize) at Microsoft.Office.InfoPath.Server.SolutionLifetime.DataAdapterListDataProvider.Execute(String siteUrl, Guid listId, SPContentTypeId contentTypeId, Document document, DataAdapterListDataProvider documentAdapter, Boolean useDcl, XPathNavigator queryFields, XPathNavigator resultFields, Boolean isListItemEditing, Boolean discoveryOnly, Int64& auxDomSize) at Microsoft.Office.InfoPath.Server.DocumentLifetime.DataAdapterListDataProvider.ExecuteInternal(XPathNavigator queryFields, XPathNavigator resultFields, Boolean useListItemMode) at Microsoft.Office.InfoPath.Server.SolutionLifetime.RulesActionQueryListItem.ExecuteRule(Document document) at Microsoft.Office.InfoPath.Server.SolutionLifetime.RuleAction.EvaluateExpression(Document document, XPathNavigator currentTarget) at Microsoft.Office.InfoPath.Server.SolutionLifetime.RulesRuleSet.EvaluateExpression(Document document, XPathNavigator targetNavigator) at Microsoft.Office.InfoPath.Server.DocumentLifetime.Document.FireRulesHelper(Boolean onLoadRules) at Microsoft.Office.InfoPath.Server.DocumentLifetime.Document.PerformOnLoadEvent(Dictionary`2 intputParameters) at Microsoft.Office.InfoPath.Server.DocumentLifetime.Document.LoadSolutionAndDocument(HttpContext context, Solution solution, DocumentMetaInformation documentMetaInformation, OnInitializeCallback onInitializeCallback, OpenParameters openParameters) at Microsoft.Office.InfoPath.Server.DocumentLifetime.Document.OpenDocumentWithSolution(HttpContext context, SPSite contextSite, Solution solution, DocumentMetaInformation documentMetaInformation, OnInitializeCallback onInitializeCallback, OpenParameters openParameters) at Microsoft.Office.InfoPath.Server.DocumentLifetime.Document.NewFromSolution(HttpContext context, SPSite contextSite, Solution solution, DocumentMetaInformation documentMetaInformation, Boolean disableFirstRequestOptization, OnInitializeCallback onInitializeCallback, OpenParameters openParameters) at Microsoft.Office.InfoPath.Server.Controls.XmlFormView.DataBindInternal(SolutionMetaInformation solutionMetaInformation, DocumentMetaInformation documentMetaInformation, String absoluteSolutionLocation, Boolean hasCloseHandler, Document& document) at Microsoft.Office.InfoPath.Server.Controls.XmlFormView.StartNewEditingSession() at Microsoft.Office.InfoPath.Server.Controls.XmlFormView.EnsureDocument(EventLogStart eventLogStart) at Microsoft.Office.InfoPath.Server.Controls.XmlFormView.<>c__DisplayClass8.b__5() at Microsoft.Office.Server.Diagnostics.FirstChanceHandler.ExceptionFilter(Boolean fRethrowException, TryBlock tryBlock, FilterBlock filter, CatchBlock catchBlock, FinallyBlock finallyBlock) 9130d182-80de-4da7-96d6-b2a566aea3e7

InfoPath Dynamic Hyperlink Field C# and Code Behind

In InfoPath, dynamically update a hyperlink field using code.
Sounded simple, but it took me a few minutes to get it straightened out.

I’ve attached the InfoPath form and the code behind files here: http://www.sharepointed.com/wp-content/uploads/2012/12/Dynamic_URL1.zip

Create a new Blank InfoPath form.

Add a Hyperlink control to the form.

In this step, I’ve set the field to Read-Only. Why? I didn’t want the user to be able to modify the field.

Change the field names. The first field (field1) is the field that will hold the URL path. The second field (field2) will hold the text that you want to display in place of the URL.

I’ve updated my fields as follows:
field1 changed to URLpath
field2 changed to URLdisplay

To quickly test this post, click on the Developer tab, then click Loading Event.

        public void FormEvents_Loading(object sender, LoadingEventArgs e)
        {
            XPathNavigator ipFormNav = MainDataSource.CreateNavigator();
            XPathNavigator assnAttachURL = ipFormNav.SelectSingleNode("/my:myFields/my:URLpath", NamespaceManager);
            XPathNavigator assnAttachDisplay = ipFormNav.SelectSingleNode("/my:myFields/my:URLpath/@my:URLdisplay", NamespaceManager);

            //Update the URL path to a document on your site.
            assnAttachURL.SetValue("http://sharepointed.com/library/taco.xlsx");
            assnAttachDisplay.SetValue("taco");
        }

To get the correct XPath values, see the screenshot below.

To see this work, in the code editor, click on Build, then Start Debugging.

A query to retrieve form data cannot be completed because this action would violate cross-domain restrictions.

Using InfoPath to retrieve data from SQL Server, I received this error:
A query to retrieve form data cannot be completed because this action would violate cross-domain restrictions.

Fix:
Update the InfoPath Form Services settings in Central Admin
Central Admin –> General Application Settings –> Configure InfoPath Form Services
Cross-Domain Access for User Form Templates

http://CA-ADDRESS/_admin/ipfsConfig.aspx

InfoPath Operation could not be completed

When trying to move an InfoPath from Prod to Test, I ran into a small problem.

Once I got to the point of needing to update my data connections, I received this error:

Operation could not be completed

The amount of detail is overwhelming!

The url for my test site was http://sharepoint:1200/sites/blah

After creating a new web app and having the network guys create a new DNS entry, the error went away.

The new url is http://test.sharepoint.com/sites/blah

Updated my data connections, no more error!

 

Who updated the form template?

What to find out who lasted updated a form template?

Scenario:

end user: “My InfoPath form has stopped working!”

me: oh, did anyone make a change to the form?

end user: “umm, not that I know of?!?!”

Inspection Time:

Open the site using SharePoint Designer.

In the left side of Designer, click on All Files.

From there, click on the Library name you are wanting to inspect.

The Library will now be open in your main panel / window.

Open the Form folder.

In there you should see a template.xsn file. *your template might be named something different, but look for the file with a Type of xsn.*

The Modified By column will show you the last user that made any changes to the template.

Case closed!

InfoPath Sucks

Yes, I said it, InfoPath sucks!

I started working with InfoPath back in 2006 and found it real easy to learn.

It is handy for creating simple forms, but nothing beyond simple.

Why?

With the most basic computer knowledge, you can open a form and view all of its contents!

Why is this bad?

Say you have an employee appraisal form.  In this form, you have a field called Manager Comments.  What if you didn’t want the employee to be able to view the contents of this field?

“Ohhh, I’d create a Rule to handle that!”

Wrong (sort of)!

If the employee opens the Form Library in Explorer View, right clicks on the form, and opts to open in Notepad.

The employee can now see every field and value in that form.  Yes, it would be a mess of XML, but…

To get around this scenario, I had to write code to submit the sensitive fields to another List.

*update*

Found one more issue.

In a Form Library, if you click on Connect to Outlook from the Library tab, all of the XML of the forms is displayed in your Outlook preview window.

The item is currently locked for editing. Waiting for item to be checked in or for the lock to be released

Workflow error:

The item is currently locked for editing. Waiting for item to be checked in or for the lock to be released.

Working with SharePoint Designer 2010 and InfoPath, I created a workflow to perform an Action once a form was submitted or changed.

The error above was stopping the workflow from running any of the Steps / Actions.

The fix was to add a Wait for Change in Document Check-Out Status Action to the workflow.  This Action should be the first item executed in the workflow.

The item is currently locked for editing

The item is currently locked for editing

Why does this happen?  Assume the workflow is being triggered the millisecond that the form is being written to the library and not waiting for all the data to finish writing.

*Note* Once the form/item is unlocked, it might take a few minutes for the workflow timer to process the item.