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:
[sourcecode language=”csharp”]
public void FormEvents_Loading(object sender, LoadingEventArgs e)
{
//Getting the Parameters from Url
string para_ticketId = string.Empty;
if(e.InputParameters.ContainsKey(“ticketId”))
para_ticketId = e.InputParameters[“ticketId”];
//Setting Parameter into Field of Form
XPathNavigator navForm = this.CreateNavigator();
XmlNamespaceManager NS = this.NamespaceManager;
navForm.SelectSingleNode(“/my:meineFelder/my:TicketID”, NS).SetValue(para_ticketId);
}
[/sourcecode]
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:
http://yourserver/sites/yourSiteCollection/_layouts/FormServer.aspx?xsnLocation=~sitecollection/FormServerTemplates/yourInfoPathForm.xsn&openin=browser&ticketId=ilikesharepoint
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 ::..
Great help – many thanks!
Hello!
You can learn how to make it work in a browser form infopath?
Thanks.