Setting data when a form is opened from a template (SP1)

R

Rob Blitz

Sorry for the newbie question...

I have a form that I'd like to populate with the user's name when they open
the form from the template located on a web server or Sharepoint site. I
know how to wire up drop down lists to secondary data sources (in SP1), but
this is just a plain old text field that holds the employee's name. Since
the user is online when they retrieve the form, their Infopath app can
connect to a Web Service or SQL database to get this info based on their
Windows login. Once the user opens the form and saves it, it's unique to
them and I won't need to make a network call for their name after that.

I'm unsure when to invoke the call: should I do it in the _Startup (for
which I can't find any documentation in the SDK, BTW)? Or in OnLoad()
handler? Are these the same thing?

Or am I even approaching this the right way?

Confused,
Rob
 
A

Andrew Ma [MSFT]

To access it, go to Tools -> Programming -> On Load Event...

--
Andrew J. Ma
Software Test Engineer
Microsoft Office InfoPath
http://blogs.msdn.com/ajma
---------------------------------------
This posting is provided "As Is" with no warranties, and confers no rights.
Use of any included script sample are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.
Please do not send email directly to this alias. This alias is for
newsgroup purposes only.


You'll want to put this in the OnLoad event handler.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



Sorry for the newbie question...

I have a form that I'd like to populate with the user's name when they open
the form from the template located on a web server or Sharepoint site. I
know how to wire up drop down lists to secondary data sources (in SP1), but
this is just a plain old text field that holds the employee's name. Since
the user is online when they retrieve the form, their Infopath app can
connect to a Web Service or SQL database to get this info based on their
Windows login. Once the user opens the form and saves it, it's unique to
them and I won't need to make a network call for their name after that.

I'm unsure when to invoke the call: should I do it in the _Startup (for
which I can't find any documentation in the SDK, BTW)? Or in OnLoad()
handler? Are these the same thing?

Or am I even approaching this the right way?

Confused,
Rob
 
R

Rob Blitz

OK, I created a web service to get the info I need. I created a secondary
data source and then bound it to the various fields where I want to display
the information. The problem is that every time I open the form (if I've
saved it locally) the data source wants to go back to the web service for
the data. In offline situations this causes an error that prevents the form
from loading.

Is there a InfoPath "strategy" for dealing with this kind of situation where
I only want to fetch the data when the form is first created from the
template? Or do I have to do the coding in the OnLoad handler to see if the
data is already there and then not call the web service?
 
A

Andrew Ma [MSFT]

You can change the secondary data source to not update on every load.

In the OnLoad handler, you can refresh the data when the machine is
connected to the internet. Use the Application.MachineOnlineState property
for this.

--
Andrew J. Ma
Software Test Engineer
Microsoft Office InfoPath
http://blogs.msdn.com/ajma
---------------------------------------
This posting is provided "As Is" with no warranties, and confers no rights.
Use of any included script sample are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.
Please do not send email directly to this alias. This alias is for
newsgroup purposes only.


Rob Blitz said:
OK, I created a web service to get the info I need. I created a secondary
data source and then bound it to the various fields where I want to
display
the information. The problem is that every time I open the form (if I've
saved it locally) the data source wants to go back to the web service for
the data. In offline situations this causes an error that prevents the
form
from loading.

Is there a InfoPath "strategy" for dealing with this kind of situation
where
I only want to fetch the data when the form is first created from the
template? Or do I have to do the coding in the OnLoad handler to see if
the
data is already there and then not call the web service?



Andrew Ma said:
To access it, go to Tools -> Programming -> On Load Event...

--
Andrew J. Ma
Software Test Engineer
Microsoft Office InfoPath
http://blogs.msdn.com/ajma
---------------------------------------
This posting is provided "As Is" with no warranties, and confers no rights.
Use of any included script sample are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.
Please do not send email directly to this alias. This alias is for
newsgroup purposes only.


You'll want to put this in the OnLoad event handler.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



Sorry for the newbie question...

I have a form that I'd like to populate with the user's name when they open
the form from the template located on a web server or Sharepoint site. I
know how to wire up drop down lists to secondary data sources (in SP1), but
this is just a plain old text field that holds the employee's name. Since
the user is online when they retrieve the form, their Infopath app can
connect to a Web Service or SQL database to get this info based on their
Windows login. Once the user opens the form and saves it, it's unique to
them and I won't need to make a network call for their name after that.

I'm unsure when to invoke the call: should I do it in the _Startup (for
which I can't find any documentation in the SDK, BTW)? Or in OnLoad()
handler? Are these the same thing?

Or am I even approaching this the right way?

Confused,
Rob
 

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