In one of my projects i had a form in which i am fetching data from a second list. In this second list there is a people field in which user can insert one or more people. And exactly these values should be displayed in my form. I tried a computed field, a textfield, a people field, but it only displayed the first value cause i choosed the displayname of the people field. If i select the people group it displayed everything (displayname, Userid and type).
So i googled and found this script and put it into my textfield:
eval(eval(DisplayName[ID = LookupFieldInMyForm]; 'concat(., ";")'); "..")
What does it do?
Well, in short it put each value of the people field from the second list and after each value it adds “;”. That was exactly what i needed.
If you want to use it for a listview box and you only want to extract the selected items you have to modify this part:
DisplayName[ID = LookupFieldInMyForm]
This it is reading the values.
I hope it helps you.
..:: I LIKE SHAREPOINT ::..
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 ::..