Infopath development

D

Daniel Hams

Dear all,

Here are the details about what we would like to do with Infopath, what we
have attempted, and what (we feel) we are currently missing - any help from
Microsoft at all would be extremely smashing and happy warmy feely.

What we are trying to do:

Use Infopath as an application "shell" - have Infopath provide much of the
application data entry functionality, but have custom File->New, File->Edit,
File->Close and remove existing entries. We also need to be able to trap the
user clicking the "Close Window" (upper right) control to prompt the user if
they have unsaved changes.

The custom toolbar / menu entries should be tied into custom C# code with
custom winforms.

N.B. The example code we are using to modify existing toolbars / menu items
can be found here:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;867442

* Plugin functionality

We would _really_ like to have access to similar functionality to the COM
add-ins in other office applications. We have experiemented with the
following functionality inside Infopath Forms to try and achieve this:

_startup and _shutdown methods

Unfortunately, we get errors when attempting to create / remove existing
toolbar controls from these functions. It seems that the XDocument object is
not fully initialised or in a good state at the time of these function calls.

form onLoad event

Same as for the _startup function - we are unable to create / remove
existing toolbar controls.

form onContextChange event

Inside this function we are able to run code that we want to create existing
toolbar controls - the big problem is that we do not have an onUnload event
in which to remove the toolbar entries! Putting a button on the form is not
good enough for us.

* Run time form design ( Schema / Stylesheet )

For some of our functionality, it would be extremely handy if we had the
ability to on-the-fly change both the underlying schema and the stylesheet of
the currently displayed input form. This functionality is optional, if we
have the ability to create C# code that acts like a plugin.

Many thanks in advance for any help we can get,

Daniel Hams
European Parliament
DG4 - service WepPublishing
Projet : Refonte partielle Europarl
 
B

Brian Teutsch [MSFT]

Great questions. Lots of details inline.

Brian

Daniel Hams said:
Dear all,

Here are the details about what we would like to do with Infopath, what we
have attempted, and what (we feel) we are currently missing - any help
from
Microsoft at all would be extremely smashing and happy warmy feely.

What we are trying to do:

Use Infopath as an application "shell" - have Infopath provide much of the
application data entry functionality, but have custom File->New,
File->Edit,
File->Close and remove existing entries. We also need to be able to trap
the
user clicking the "Close Window" (upper right) control to prompt the user
if
they have unsaved changes.

InfoPath doesn't directly let you disable those functions. They all have
imporant functionality to the end user, like using Edit->Copy to move data
between fields. You can use the commandbars object to disable items
yourself, and the KB article you reference below is the right way.

There is no OnClose event either. We suggest disabling Save, and using
Submit if you must do custom actions when closing a form. What you've
suggested is a little strange, however, because InfoPath already has great
UI for asking the user to save changes, and warning them about validation
errors.
The custom toolbar / menu entries should be tied into custom C# code with
custom winforms.

Hosting InfoPath within another application is not supported.
N.B. The example code we are using to modify existing toolbars / menu
items
can be found here:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;867442

* Plugin functionality

We would _really_ like to have access to similar functionality to the COM
add-ins in other office applications. We have experiemented with the
following functionality inside Infopath Forms to try and achieve this:

_startup and _shutdown methods

Unfortunately, we get errors when attempting to create / remove existing
toolbar controls from these functions. It seems that the XDocument object
is
not fully initialised or in a good state at the time of these function
calls.

InfoPath lets you hook up custom buttons easily, using our XSF syntax. You
can have your own code living behind those buttons. It does not have global
reach like an Office add-in, but otherwise is simple to do.

It sounds like you are doing something unusual to the commandbars, because
adding and removing buttons should not interact with XDocument.
form onLoad event

Same as for the _startup function - we are unable to create / remove
existing toolbar controls.

form onContextChange event

Inside this function we are able to run code that we want to create
existing
toolbar controls - the big problem is that we do not have an onUnload
event
in which to remove the toolbar entries! Putting a button on the form is
not
good enough for us.

See above. _startup and _shutdown are definitely the correct place.
* Run time form design ( Schema / Stylesheet )

For some of our functionality, it would be extremely handy if we had the
ability to on-the-fly change both the underlying schema and the stylesheet
of
the currently displayed input form. This functionality is optional, if we
have the ability to create C# code that acts like a plugin.

Infopath is completely a data-driven application. Changing the schema of a
data-driven application is not something that you'll be able to do. Why do
you think it's critical to change the scheam, instead of making the schema
flexible to handle the range of possible data?

But using data to drive the view, is most definitely supported. Using things
like conditional formatting and conditional visibility, using multiple views
to display relevant information and using dynamic controls like optional
sections are core functions of InfoPath.
 
D

Daniel Hams

Hi Brian,

Thanks very much for the reply - greatly appreciated. I am attempting to get
some direct contact through our support at the Parliament as that might be
easier than newsgroup exchanges. If I find anything additional out, I'll post
in the newsgroup to benefit all.

Some additional info on what we are trying to do:

We wish to add menu items to infopath, and these menu items should call c#
code that displays a winform that communicates with our Java web service.
We've already got the Java web service / .NET connectivity working - our
problem is that we cannot put code behind the menu items unless an InfoPath
form is currently open.

We don't so much want to embed InfoPath within another application as
'extend' InfoPath with some custom business functionality that talks to our
server (Its a Documentum web publishing type thing). E.g. User clicks our
menu, gets to choose where content is created / what type of content they
want to create plus the language, plenary session... you get the idea :)

When the user is done with the form, we will be submitting the XML content
to a web service to store as XML fragments inside Documentum for later
publication management. Form is closed, but our menu entries and custom code
is still available.

I've added some more comments to the text below.

Brian Teutsch said:
There is no OnClose event either. We suggest disabling Save, and using
Submit if you must do custom actions when closing a form. What you've
suggested is a little strange, however, because InfoPath already has great
UI for asking the user to save changes, and warning them about validation
errors.

I gotcha - if we flag the dirty bit using code will this prompt the user to
save / submit on close?
Hosting InfoPath within another application is not supported.

Not really what we would like to do as per above.
InfoPath lets you hook up custom buttons easily, using our XSF syntax. You
can have your own code living behind those buttons. It does not have global
reach like an Office add-in, but otherwise is simple to do.

It sounds like you are doing something unusual to the commandbars, because
adding and removing buttons should not interact with XDocument.

In the KB article mentioned, the adding / removing of toolbar entries is
done with the XDocument object:

Microsoft.Office.Core.CommandBars objCommandBars =
UnwrapCommandbarsObject( (ObjectWrapper)
thisXDocument.View.Window.CommandBars );

Unfortunately, when we attempt to perform such operations in the _startup,
_shutdown and form onLoad methods, we get an 'object is in invalid state' on
this line of code (sorry I can't remember the exact message - I'm at home now
its like 1.00 am :)

It feels like the wrapper objects for the XDocument object are not
initialised at the time we try to use them.

We also tried launching a separate Thread with a sleep to see if we could do
the operation later on. This got really wierd, as if we used a sleep of 30
seconds in the Thread before calling the code, we could get the toolbar code
to work _from a button in the form_, but when the Sleep expired and the
Thread attempted to call the code = bingo = same 'bad object state' problem,
but after we have successfully done it using the button on the form.
Infopath is completely a data-driven application. Changing the schema of a
data-driven application is not something that you'll be able to do. Why do
you think it's critical to change the scheam, instead of making the schema
flexible to handle the range of possible data?

We just thought it could be kinda funky in a MS Access 'run-time-design'
madness kind of way :)

Great to get your response Brian,

Weather here is crap. My cat says Hi.

Dan
 
B

Brian Teutsch [MSFT]

This is gonna get messy below, so...
Buttons not working without an open form -
This may be true, I don't think we've heard anyone try it without an open
form. I think we'll have to investigate deeper. The difference between a
button inside the form and in the toolbars is curious. I'll try to get some
deeper answers.
Dirty bit -
Yup, setting that will prompt save/submit.

If you can't find PSS contacts, feel free to "correct" my reply-to address
and contact me directly.

Brian
 
Top