Showing posts with label InfoPath. Show all posts
Showing posts with label InfoPath. Show all posts

Monday, 13 February 2012

Setting InfoPath promoted properties (boolean type) through SharePoint has no effect.

I have an InfoPath form that contains some boolean (true/false) fields that being promoted to list columns upon publishing. However when I updated those values through SharePoint starndard property page and then opened the form itself the changes are not reflected. After hours of digging, it turned out that InfoPath service can only handle boolean value as 1/0, instead of true/false or 1/0 by the InfoPath thick client. Once I forced all the boolean fields and corresponding controls in the InfoPath form to be 1/0 instead of true/false, everything works fine.

Monday, 6 February 2012

Error when publishing InfoPath form containg sandboxed code to a SharePoint form library


When I tried to publish an InfoPath form with codebehind to a form library, I got the error "The form template has been published to the server but it can only be opened in the InfoPath Filler". And it complained that there is something wrong with the InternalStartup method in the code. It turned out has something to do with the fact that the machine (VM) I published to is also acting as a domain controller. Changing the permission setting of 3 registry keys will resolve the issue.

http://support.microsoft.com/kb/2026191

Tuesday, 29 November 2011

Manipulate Infopath Dropdown List Through Managed Code

You cannot manipulate the form control directly, you can only manipulate the data source the control is bound. In the following example I have a data connection to get data from a SharePoint List, and the dropdown list has been configured to bind to the data connection. In the button click event I manually created a new item, append it to the list and then select that item.

public void CTRL6_5_Clicked(object sender, ClickedEventArgs e)
{
DataSource ds = this.DataSources["Customers"];
ds.QueryConnection.Execute();
XPathNodeIterator nodes = ds.CreateNavigator().Select("/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW",this.NamespaceManager);
XPathNavigator lastNode = ds.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW[" + nodes.Count.ToString() + "]", this.NamespaceManager);

XmlDocument doc = new XmlDocument();
XmlElement newNode = doc.CreateElement("d:SharePointListItem_RW", this.NamespaceManager.LookupNamespace("d"));
newNode.AppendChild(doc.CreateElement("d:Title", this.NamespaceManager.LookupNamespace("d"))).InnerText = "Jeff";
newNode.AppendChild(doc.CreateElement("d:ID", this.NamespaceManager.LookupNamespace("d"))).InnerText = "99";

lastNode.InsertAfter(newNode.OuterXml);

this.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:field1", this.NamespaceManager).SetValue("Jeff");
}