InfoPath is a powerful tool which can be customized by using rules or custom code behind. At one of my projects it was necessary to display some additional information from a database dependent on which checkbox the user clicked / checked. Another request to this was that the form has to be browser-enabled cause it should be displayed in a SharePoint environment.
So i have 3 Checkboxes: A, B, C. And i have a section with a repeating table which is structured like this:
I use the onchange Event of each Checkbox which calls the function. Now let’s see how we can fill this repeating table with data: (more…)
I already posted about how to set a date field in infopath by code behind. If you like to read this post, just look at this post. But this post i am gonna explain how to set the date field correctly by just using rules or the formula.
So we should look at first at the anatomy of the date. Mostly you know the date as
or whatelse. It does not matter. You have your date field and set the format as you like. But you can see that infopath saves the date always in this way:
yyyy-mm-ddThh:mm:ss – example: 2012-11-18T12:00:00
If you know that, you are able to use formulas to fill a date field with correct dates. So you have to use a “T” as separator between the date and the time.
If you would like to pass parameters into an InfoPath form, for example to call specific data into the form you can do it really easy. In my case we are using code behind, i am not sure if you can read parameters without using code, but if it is possible please let me know.
As i said you need to add code behind into your form, in order to access the parameters. Afterwords you have to insert the form loading event and use these lines of code:
public void FormEvents_Loading(object sender, LoadingEventArgs e)
//Getting the Parameters from Url
string para_ticketId = string.Empty;
para_ticketId = e.InputParameters["ticketId"];
//Setting Parameter into Field of Form
XPathNavigator navForm = this.CreateNavigator();
XmlNamespaceManager NS = this.NamespaceManager;
By using the e.InputParameters["yourparameter"] you can access the values of the parameter. By using the contains key you can check if the parameter is attached to the url. This is important that you don’t get an error message cause the parameter is missing. It’s better to check it by yourself and give a nice error message to the user.
Now your InfoPath form can read the parameter and write it into any field you like. If you open the InfoPath form by using this adress:
The InfoPath form writes this value “ilikesharepoint” into the desired field:
Hope this helps you a little bit. If you would like to know more about, i recommend you to read this great post.
..:: I LIKE SHAREPOINT ::..
This post is based on my previous article in which i describe how to deploy an InfoPath form via Visual Studio Solution. Please read it first and then come back to this post cause we will use the example and add the code behind.
Ok, if you like to add code behind in your InfoPath form you normally have installed the VSTA Addin in your Office package. Afterwards you can choose which language for programming you would like to have.
After that you can add a loading event to your form.
It opens the Visual Studio Project.
Now you can deploy this project and you will find a .dll in your bin folder. Remember this. But first you publish your form again and put it into your solution again like in my previous post. (more…)