Thanks to Ranjit Batra who chalenged me to create a control similar to what is exist in Lotus Notes.
This control emulates multiple choice control that is not available in InfoPath. Enjoy!
Thanks to Ranjit Batra who chalenged me to create a control similar to what is exist in Lotus Notes.
This control emulates multiple choice control that is not available in InfoPath. Enjoy!
There are not so many differences in versions of XPath between regular forms and web enabled ones. But inability to reference rows in web enabled forms by the index is one of the most annoying. Here are several XPath formulas useful when interacting with repeating tables:
1. The current row index expression:
count(preceding-sibling::*[local-name() = "MyRepeatingGroup"])
As you can see that formula successfully substitutes the position() function not available in web forms.
2. Accesing value of the previous row:
preceding-sibling::my:MyRepeatingGroup[count(preceding-sibling::my:MyRepeatingGroup) = count(current()/preceding-sibling::my:MyRepeatingGroup) - 1]/my:FieldToAccess
3. Implementation of the last() function:
my:MyRepeatingGroup[count(following-sibling::*[local-name() = "MyRepeatingGroup"]) = 0]/my:FieldToAccess
4. Count all rows that have duplicates:
count(my:MyRepeatingGroup[following-sibling::*/my:FieldToAccess = my:FieldToAccess])
5. The other technique demonstrates idea of how to wright into repeating group by providing index of the row and a value:
Form to try.
Happy codeless programming!
If you think it’s a decent solution vote for it! :)
Work days between 2 dates:
public static double GetBusinessDays(DateTime startD, DateTime endD)
{
double calcBusinessDays =
1 + ((endD-startD).TotalDays * 5 -
(startD.DayOfWeek-endD.DayOfWeek) * 2) / 7;
if ((int)endD.DayOfWeek == 6) calcBusinessDays --;
if ((int)startD.DayOfWeek == 0) calcBusinessDays --;
return calcBusinessDays;
}
Add work days to a start date:
DateTime startD = new DateTime(2000, 5, 28);
double businessDays = 2300;
int DoW = (int)startD.DayOfWeek;
double temp = businessDays + DoW + 1;
if (DoW != 0) temp --;
DateTime calcendD = startD.AddDays(
Math.Floor(temp / 5)*2-DoW + temp
- 2* Convert.ToInt32(temp % 5 == 0)) ;
Special thanks: Karl D. Swartzendruber
First of all you have to place your repeating group into the non repeating one. So your field structure should be looking like that:

Field structure
Then as you can see the simple rule f=cleaningGroup will delete all rows. Now we are getting to the point why it never been implemented before. As soon as you will try to assign any value to a group InfoPath will yell at you with the message: “You must select a field. Groups do not have values and therefore cannot be assigned to by this action.” Let’s prove that at least “cannot be assigned” part of that statement is false.
It’s time for some rule breaking.
Now we will screw up the group (“f” in our case) by giving it a temporary name. Create a field at the same level as your group formerly named “f”. Name that field … guess what? Right, with the name “f”. Now InfoPath UI won’t be objecting when you’ll try to create button rule f=cleaningGroup. Delete field “f”. Rename your group back to its original name: “f”.
The Form to test. Web browser forms OK.
Deleting single row from the repeating field.
Here is form that is doing exactly this. The way it was created (renaiming hack) is similar to the previous form. There are several limitations assosioated with this approach. First is it supports single repeating field not repeating group. Another “feature” you have to consider before you decide to use this form is unchecking checkbox at single row will delete all rows with the same value (might be useful in certain scenarios). Also because of Multiple selection check box this form can be made browser enabled in SP2010 only.
1) Create field called InitialState
2) At open event assign InitialState field to the following Xpath expression:
.. Yes, it’s two dots :)
3) At the submit rule compare InitialState field with the following expression assuming it’s a rule condition at a button:
starts-with(., my:InitialState)
Make sure the InitialState field is a very last node in the myFields group fields list.
I also believe some people might find interesting the way I used conditional expression to parameterize output message.
Form with more advanced XPath (InitialState can be at any position)
Other parts: 1, 2.
Bookmark that post
I hope this will be the last publication about codeless programming in InfoPath. In the first two parts I demonstrated few examples where we can see implementations of ‘while’ and ‘if’ like operators. The only area remained uncovered is block of code reusable by multiple controls (analog of procedure/function). Hopefully that approach will be able to address quite frequent complains about absence of ability to copy set of actions/rules across similar controls in InfoPath UI. The essential element of that approach is hidden field with shared set of actions/rules. Form to download
Happy codeless programming!
You can tag any element on your portal with the comment. The comment becomes visible for everybody who are at the same page and have Discussion tollbar open. It works as instant messaging too.
When you are at any page of your portal go to the IE explorer menu bar Vew->Explorer Bars->Discuss.
Use the button “Insert Discussion in the Document”. The server will highligt all places on the page you could tag with a comment.
Type in your comment.
That feature is available because Office Server Extentions are part of Sharepoint installation.
Link about Office Server Extentions and thier relation to SharePoint.
There is no out of the box way how to create custom view which supports merge functionality. But such minor obstacles shouldn’t stop you from creating as many merge views in your library as you want.
1) Click “Create new view” link in your form library
2) Navigate to the “Start from an existing view” section (and we going to do so not to just one more time to ensure that merge view are not presented among proposed choices)
3) Right click on any of the choices and copy shortcut to clipboard
4) Open NotePad (or any other editor) and paste
5) Open existing merge view and click “Modify this view” link
6) Copy part of the hyperlink in your browser which is in between ‘View=%7B’ and ‘%7D&Source’
7) In NotePad replace part from ‘View=’ to the end with information from your clipboard
8) Copy resulting link into addres bar of the new browser window and press “go to” button.
9) Enjoy your new and shiny merge supporting view :)