hi all
i have an IP form containing several views. i also have a custom
taskpane that provides the user navigation around all these views.
upon completion, the user then submits the form to a web service for
processing.
the consumption of the form data by the web service can take a long
time, particularly with large amounts of data. in order to make this
process friendlier for the user, i want to temporarily switch to a
simple "Please Wait" view for the duration of the long operation, then
switch back to the previous view.
however, if two SwitchView command are issued in succession, IP throws
the "InfoPath cannot execute any view-related object model calls. The
view is not ready." error.
i have tried using a deferred switching method, whereby the user's
submit action first sets a global boolean variable to true, then
switches to the "Please Wait" view. then in the OnSwitchView event,
the global variable is checked and if true, performs the submits to
the web service, then attempts to switch back to the previous view.
i figured that isolating the two SwitchView calls this way may have
worked, but it causes exactly the same error.
i'd really like to be able to provide this UI enhancement.
is there any way at all that i can achieve calling SwitchView,
performing a long operation, and then calling SwitchView again?
thanks
roland
Brian Teutsch [MSFT] - 02 Sep 2004 23:50 GMT
You can't call SwitchView twice within the same business logic call. What is
the reason you're trying to do two switches, instead of just having logic to
go directly to the final view? Perhaps we can help you rework your scenario
to get the end goal without using two SwitchView calls.
Brian
> hi all
>
[quoted text clipped - 29 lines]
> thanks
> roland
Matt N - 21 Mar 2005 16:45 GMT
I find it interesting that the view can't be modified twice by one call. If
someone had need to export several views there would be no way to automate
that task as export is a view method (Xdocument.view.export).
Possible scenario:
A user enters data into a data entry form. Several business partners (that
do not use infopath) need that data, each with their own formatting
requirements. An mht export would serve this purpose if a print view was
set up for each partner (although a Word export would be better if only
Infopath supported it). It would be nice to have a single button on the
data entry form that is programmed to export all of the mht files.
Abbreviated:
//from Data Entry View
XDocument.View.SwitchView("Contoso Version Export");
XDocument.View.Export("C:\Contoso_Exports\" + name, "MHT");
XDocument.View.SwitchView("ACME Version Export");
XDocument.View.Export("C:\ACME_Exports\" + name, "MHT");
XDocuemtn.View.SwitchView("Data Entry View");
This would fail at the second line with a "view not ready" error. Because
you can only export the current view (as opposed to passing the view as a
parameter to export), the view must first be changed, which is not required
(and undesirable) for the user.