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

Wednesday, 26 September 2007

Infopath Development Tips 1 - Infopath repeating table manipulation

Infopath forms are the essential part of sharepoint workflow development. Repeating table is also very tempting because it can solve many UI problems when presenting group of data. So the problem is , how do we populate repeating table from the data we have. It's easy. AppendChild method of DOM using managed code and Infopath's powerful conditional formatting.
1. First thing first, let's specify the conditional formatting for repeating table. right click the table, then properties->conditional formatting-> add. Then you can specify when the value of element of table, say , text box is blank, tick "hide this control". This will make sure your table doesn't show extra blank row when inserting the rows. We will see why we might need to hide this row later on.

2. Secondly, we need to use a little code behind to populate the table we have in the IP form. Say the name of the table we have is called docList and the collection of data we have is docArray. so the code will be



//repeating table

relDocListTable = mainRoot.SelectSingleNode("/my:myFields/my:docList", this.NamespaceManager);


//repeating table row
relDocListRow = mainRoot.SelectSingleNode("/my:myFields/my:docList/my:docItem", this.NamespaceManager);

for (int index = 0; index < newrow =" relDocListRow.Clone();" innerxml =" docNameArr[index];">

Thursday, 12 April 2007

Check if current form client is rich or thin by code

Since you can make the InfoPath form both web/Infopath compatible, sometimes you might need to tell if the user is using a thin-client with a web browser to fill in the form or a rich client instead because functionalities like some data validation, popup message, custom task pane etc, will not appear in the web browser at all. It's easy to tell by using property IsBrowser


//if it's rich client user environment
if(! Application.Environment.IsBrowser)
{
//do something that is only available for client with Infopath installed
...
}

Wednesday, 11 April 2007

dynamic data using XPath functions for your InfoPath 2007 form elements

As MS advertises VSTO(Visual Studio Tools for Office) and its little bro VSTA(VST for Application) which is the conversion of VBA into vb.net/c# solution(which is good, I personally dislike VBA :p), InfoPath form can be developed by accessing form data dynamically using XPath.XPathNavigator such as following :


XML.XPath.XPathNavigator root,myField;
root = this.MainDataSource.CreateNavigator();
myField = root.SelectSingleNode("//my:myField",this.NamespaceManager);




then you can using myField.SetValue() /myField.Value to set/get the value of your textbox, dropdownlist and more...

In here, I want to introduce an interesting use of XPath functions built in to InfoPath. It's a scenario that you want to use a hyperlink to call out an email client installed on your local machine and fill out the form data on the client,say Outlook to prepare an email for your disposal in which case, VSTA/VSTO might be a bad/harder solution to implement(you don't get the address your hyperlink is pointing to since your hyperlink doesn't appear to be a xml node not in xml file at all...)

we all know that the RFC standard URL mailto: will get you the client :e.g. Outlook Express or Outlook for you with the subject, cc or whatever you append in the mailto string. But in InfoPath form, after you inserted a hyperlink and try to call out an email client, you might wonder how on earth you gonna have to type in this url in the text box, and the fatal shortcoming for this is that you don't get dynamic datafrom your form. Well, it's easy, using XPath fn : concat(string, string, my:myfield) in your data source field in the hyperlink property box. so you can use both static and dynamic data this way. see illustration


Hope this will save someone's time.Enjoy!