Tuesday, April 30, 2013

SharePoint 2010 List: Customize Form with Infopath Bug with Calculated Columns

I recently stumbled upon a bug with the 'Customize Form' feature on a SharePoint List. If you have a calculated column in your SharePoint List and are trying to represent it with reduced number of decimal places, either directly through the cloumn definition or through a calculated formula (such as ROUND() etc.), the value is calculated and displayed correctly in the List Views, but when you open the individual list item in an infopath form, Infopath represents the entire number, including all the decimal places, and does not respect the original column definition or any calculated formula.

The bug can be rec-created by following the steps below:

1) Create a simple Custom List  and add two columns, one called Numerator (a 'Number' type of Column) and the other one called a Denominator(a 'Number' type of Column), as shown in the screenshots below:
Numerator Column


Denominator Column

2) Add a third column, a 'Calculated' type of Column, called Num/Denom that simply divides the Numberator by the Denominator. Make sure you set the number of decimal places on this column as zero, as shown in the screenshot below:

Num/Denom Cloumn
3) Now, try to Click on 'Customize Form' in Infopath and add the Calculated Column created in Step 2) to the Infopath form, as shown in the screenshot below:


'Customize Form' View

4) Now try to add a new list item, you will notice that even though the Num/Denom is calculated and displayed correctly in the All Items view (see screenshot below), it is not displayed correctly when you open the list item (see screenshot below).



List View


The Individual List Item View
At the time of writing this blog post, I have not reported the bug to Microsoft but will be doing so soon.