Pre populate InfoPath fields

  • 7 October 2005
  • 3 replies
  • 1 view

Badge +4
Hello all,

I want to know how to pre populate InfoPath fields, in a K2 process context, before the form actually displays to users. For instance, inserting the user's name into the appropriate field therefore saving filling time as the user does not have to type these informations.

I want to this at the start of the process and any subsequent activities.

Thanks,

3 replies

Badge +3
At the risk of not actually answering your exact query, you could use code within the InfoPath form to evaluate System.Environment.UserName which returns the login name of the current user. With that you can query Active Directory for additional details.

Hope this helps, even a little. :)
Badge +4
Your answer seems to be on the right track.

Nevertheless, being a newbi at all of this, I would need a little bit more explanation.

1- Where, in the InfoPath form, would I put that code?

2- Do you have VB.Net code examples in querying the Active Directory?

Thanks,
Badge +3
No problem. Place the code into the OnLoad() event within your form.

You can read about querying Active Directory within InfoPath in this example:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_ip2003_tr/html/odc_INF_Lab_15.asp

For more background on AD, this link gives a good account of how to Query AD with C# - the VB.Net functions are equivalent, just check the .NET Framework documentation.
http://www.codeproject.com/dotnet/QueryADwithDotNet.asp#xxxx

By the way, I coded my solution using a web service to handle the query of Active Directory, but you can code it directly into the form if you wish.

Reply