Uploading infopath form with managed code to MOSS

B

Brian Farnhill

Hey,

I have an infopath form that I want to try in the web browser just to see if
it runs. It only has a single text field that in the startup event of the
form populates with the users windows name. The code I use is

When I upload the form into the central administration of the MOSS server I
get these errors:

MainDataSource.CreateNavigator.SelectSingleNode("/my:myFields/my:field1",
NamespaceManager).SetValue(System.Environment.UserName)

This operation is not allowed at this time.
There is an error in the InternalStartup method of form code.

Any ideas what is casuing this?
 
S

S.Y.M. Wong-A-Ton

The InternalStartup is for hooking up event handlers by InfoPath. Remove your
code from the InternalStartup and try putting it in the Loading event (Tools
 
B

Brian Farnhill

Thanks, that got it uploaded and I could put it into a forms library.

Now I don't suppose you could help me with somethign else related to the
same issue. I am basically trying to prepopulate one of the fields with the
current users windows name when the form loads, using that line of code
below. I need to form to run as a web page (in the browser, so the clients
are not required to have infopath installed). When I go to create a new form
it tells me that an error occured loading the form. Any ideas why or what I
can do?
 
B

Brian Farnhill

Thanks David. I read that blog post and I changed to code to get the users
logon with Application.User.UserName instead of System.Environment.UserName
and it works perfectly.

The function also worked, but my end game for the forms I'm working on would
involved managed code that queires a web service to return properties on the
user from some of our line of business systems and then prepopulating the
form with that information - I dont really want to have a field with thier
username on the form at all.

Thanks again for the info, this has definately pointed me in the right
direction!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top