Friday, February 10, 2012

Value field from dropdown infopath

Hi all,
One question always asked by developer is how to get the Text value of dropdown control ? There are many more article available in web.But the problem arises when the drop down having static data no secondary data available.

what we can do is we can create a XML file having our required data. below a sample file.

<?xml version='1.0' ?>
<bookstore>
<book>
<title>Sample Data 1</title>
<id>1</id>
</book>
<book>
<title>Sample Data 2</title>
<id>2</id>
</book>
<book>
<title>Sample Data 3</title>
<id>3</id>
</book>
</bookstore>


now we can do the necessary filtering to get the value data.

Thursday, February 9, 2012

Day of week from date picker

Hi All,

today i found some use full trick to get the Day of the week from Date time picker of infopath in browser enabled.

Step 1 :

Create a Date picker control lets say FldDate.

Step 2 :
Create a Textbox control lets say FldDayOfWeek.

Step 2 :
Add following rule to the FldDate

(number(substring(., 9, 2)) + number(number(substring(., 1, 4)) - (floor((14 - number(substring(., 6, 2))) / 12))) + floor(number(number(substring(., 1, 4)) - (floor((14 - number(substring(., 6, 2))) / 12))) / 4) - floor(number(number(substring(., 1, 4)) - (floor((14 - number(substring(., 6, 2))) / 12))) / 100) + floor(number(number(substring(., 1, 4)) - (floor((14 - number(substring(., 6, 2))) / 12))) / 400) + floor((31 * number(number(substring(., 6, 2)) + 12 * (floor((14 - number(substring(., 6, 2))) / 12)) - 2)) / 12)) mod 7

set value to the FldDayOfWeek.

Step 3 :

Add another rule like
if FldDayOfWeek == 0 then set "Sunday" to FldDayOfWeek
if FldDayOfWeek == 1 then set "Monday" to FldDayOfWeek

like wise create 5 more rule for other days week.

Now all set. if you select a particular date in Date Picker control it will show you the Day (like Sunday,Monday..).