Archive

Archive for the ‘Infopath’ Category

InfoPath: Hide command text for conditionally inserting row in repeating table

June 2nd, 2010 4 comments

Problem 1: Allow the users to insert a row in repeating table based on condition evaluation.

Solution:

  1. Select the repeating table, right click on it to open up context menu.
  2. Click on “Repeating Table Properties…” > “Display Tab” > “Conditional Formatting…” button. It will open up “Conditional Formatting” dialog.
  3. Click on “Add…” to open up “Conditional Format” dialog.
  4. Select the condition and check “Don’t allow user to insert or delete this control” as shown in the image below.
  5. Click OK button on every open dialog.
  6. Now preview the form. Based on evaluated condition, clicking on “Add Employee” will either allow or don’t allow you to insert a new row.

Problem 2: Above mentioned solution does not hide the command text “Add Employee” so user may try to click on it but nothing happens. The problem is to hide a command text.

Solution: Read more…

Categories: Infopath Tags:

InfoPath: Conditionally Hide Hyperlink Control

April 30th, 2010 1 comment

You may have been to a situation where you have to conditionally hide the hyperlink control but unlike many other InfoPath controls, hyperlink controls does not support conditions. But there is a way to hide this control. :)

Here is my main data source.

IsVisible is a boolean field and Hyperlink is a string storing URL. I want to show the URL only when IsVisible is “true”.

Solution: Read more…

Categories: Infopath Tags:

InfoPath: A proper way to blank out Whole Number, Date using JScript

April 29th, 2010 No comments

Problem:

When you blank out data in InfoPath using JScript, you would probably use the following method.

XDocument.DOM.selectSingleNode("my:xpath/my:node").text = "";

Above code works well when “my:node” is of data type String. If the data type is Number or Date, above code will work but on the user interface you will see an error “Only integers allowed.” and “Only date allowed.”

Only integer allowed Read more…

Categories: Infopath Tags: , , ,

InfoPath Error: Reference to undeclared namespace prefix “dfs”

March 17th, 2010 3 comments

Error:

If you are trying to get/set values using XPath on Secondary Data Source, you might get the error “Reference to undeclared namespace prefix: dfs”.

Cause:

When you are trying to use XPath expression on Secondary Data Source, you must have to declare the namespace that is going to be used in the code. By default, InfoPath does NOT add namespace for Secondary Data Source. You have to add it manually.

Resolution: Read more…

InfoPath Hyperlink Control: Show Hyperlink Based on Filtered Data

March 11th, 2010 No comments

In InfoPath, Hyperlink control does not support filtering data when you select a field for repeating group. But you can definitely avert this limitation using a trick. For example, I have secondary data source “Data” as xml file with the following content

<?xml version="1.0" encoding="utf-8" ?>
<Settings>
    <Setting Name="Users" Value="2" />
    <Setting Name="WebAddress" Value="http://blog.vishalon.net" />
</Settings>

Now I want to get a hyperlink out of “Value” attribute of “Setting” node whose “Name” is “WebAddress”. Read more…

Review of InfoPath forms functionality in Business Productivity Online Suite (BPOS)

November 13th, 2009 No comments

I got some hands on experience about Business Productivity Online Suite(BPOS). Its a great tool for small companies who wants to have exchange server, office communicator, sharepoint and live meeting for their business needs. I do have experience with SharePoint and InfoPath but this assignment was quite challenging.

Well, What’s the challenge?

  1. New assignment requires me to use InfoPath forms to reduce client’s paperwork.
  2. Many bloggers have written that InfoPath form is not supported in BPOS standard suite.
  3. Client does not want to invest in buying InfoPath. Many of client users are contractors and client does not want to buy license if they need to.

So how I am going to do?

InfoPath is supported in BPOS standard suite. Even browser enabled InfoPath forms are supported.

So why am I writing review?

Well, even though InfoPath is supported, there are lots of limitations that I want to share with you. Of course, if the client would have got InfoPath license, my life would have been much easier but I love challenges. I had previously not worked with browser enabled form so it was a new concept for me. When I initial though of creating solution, I thought that InfoPath form is backed by .Net power so I don’t need to worry about anything and I will quickly put the solution but I was wrong. Here is a good list of InfoPath 2007 features those are not supported in InfoPath Form Service. This is a limitation of Form Service. On the top of it, there is a limitation of BPOS which cripples how we develop the solution.

Here is a list of limitations of InfoPath form Service and BPOS that I confronted so far.

  • I cannot use any kind of .Net code
  • I cannot retrieve data from SharePoint List/Web Service (throws evergreen LogID 5566 error. This error occurs because of certificate name – as per support response) using custom views.
  • Some of the controls are not supported in browser enabled forms.
  • BPOS does not support data connection library in standard suite so I have to manually change the URL while moving forms from staging site to production.
  • Browser enabled form does not support mobile view.

Here is a list of what you can do with it?

  • I can only use Rules, Conditional formatting and Data Validations.
  • You can get all data from the list but not from particular view.
  • It supports multiple view. You can even hide view and open it (for example) by clicking on a button.

Subtract Time in Infopath

January 13th, 2006 2 comments

Infopath is a great tool for rapidly developing an application which
gathers information from the user. Many times these applications uses
start time and end time as their fields. Infopath has a “Time”
datatype. We can directly assign this datatype to the fields. You can
compare two fields of this datatype but substraction of fields is not
handled. You have to manually parse the field value, subtract the
values and change the appropriate fields. Here is the proposed solution
of this problem.

This solution contains 3 functions

  1. UpdateHours()
  2. convertJScriptNumberToXML()
  3. roundFloat()

Lets see all these functions one by one.

function UpdateHours(){
	var TimeIn = XDocument.DOM.selectSingleNode("/my:Time/my:StartTime").text;
	var TimeOut = XDocument.DOM.selectSingleNode("/my:Time/my:EndTime").text;
	var index1 = TimeIn.indexOf(":");
	var hi = TimeIn.substring(0,index1);
	var index2 = TimeIn.indexOf(":", index1+1);
	var mi = TimeIn.substring(index1+1, index2);
	index1 = TimeOut.indexOf(":");
	var ho = TimeOut.substring(0,index1);
	index2 = TimeOut.indexOf(":", index1+1);
	var mo = TimeOut.substring(index1+1, index2);
	var ti = parseFloat(hi) + (mi/60);
	var to = parseFloat(ho) + (mo/60);
	var tt = to - ti;
	var node = XDocument.DOM.selectSingleNode("/my:Time/my:TotalHours");
	if (tt != "" && node.getAttribute("xsi:nil"))
		node.removeAttribute("xsi:nil");
	node.nodeTypedValue = convertJScriptNumberToXML(tt);
}

As
the name suggests, this function updates the value of “TotalHours”
field. First of all, it will get the value of “StartTime” and “EndTime”
field. The value will be in the format of HH:MM:SS. So the value will
be parsed according to the position of “:”. Both the values will be
converted inot the float representation. Now value will be sutracted
and the result will be stored in “TotalHours” field.

function convertJScriptNumberToXML(value){
	var retVal;
	switch (value)	{
		case Number.NEGATIVE_INFINITY:
			retVal = "-INF";
			break;
		case Number.POSITIVE_INFINITY:
			retVal = "INF";
			break;
		case value:
			retVal = roundFloat(value,2);
			break;
		default:
			retVal = "NaN";
	}
	return retVal;
}

This function converts the actual number into text based value. Here he number will be rounded upto 2 digits.

function roundFloat(value, decimalPlaces){
	if (value < -1E15 || 1E15 < value)
	{
		return value;
	}
	else
	{
		var nPowerToRound = Math.pow(10, decimalPlaces);
		return Math.round(value*nPowerToRound)/nPowerToRound;
	}
}

This
function actually rounds the float value to the required decimal place.
To apply this code to your application, copy/paste these three
functions into the script file. In the “OnAfterChange” event of start
time and end time field, call the function “UpdateHours”.

Note: Please put the downloaded code in C:\

Categories: Infopath Tags: