Accessing Infopath rules without opening Infopath form

This just may not be possible, but thought I would throw it out there:

The base question:  Is there a way to execute Infopath rules without actually opening up an Infopath form with the Infopath client?  I don't believe there are Infopath APIs to be called from .NET code but maybe I'm wrong or is there some other way to access the rules "virturally" within code.  

Background:  I work for a company that has workflow software where we can update an Infopath form with data captured within our system and we're using the Infopath form as the user interface.  We only want the user to get the Infopath form if there are errors present, otherwise send the form on to the next steps in the workflow.

We're using an Infopath 2007 form which will be published to a MOSS document library.  Using an XML doc created by opening the form and saving it without adding any data, we will then add  data.  From there we need to validate the data using the rules created within Infopath.  We know we can capture the number of validation errors to store on a field on the form to use later, but it requires quickly opening and closing the form programmatically (the rules execute on open).  Our worry is that there could be hundreds of forms opening and closing which could hog server resources and create other errors as we do this.  Ideally if there was a way to access the error count through .NET code, we wouldn't have to worry about opening and closing the form.  

Any ideas or are we just dreaming?? Thanks.
TicketKevAsked:
Who is Participating?
 
hstaples53Connect With a Mentor Commented:
Here's a couple of ideas; either way you're basically having Infopath run in some context (whether it be an ASP.NET page or an EXE)

1) Server-side call to Infopath Forms Services

You'll still need to open the form and have the rules processed through Infopath, but I'd run the forms through Infopath Forms Services so it's done in something that's made to handle opening a bunch of forms at the same time.

To get Forms Services working for you:
* If you have MOSS Enterprise installed, then click Site Settings, Site Features, and make sure the SP Enterprise Features are activated. That'll give you Forms Services.
* Make sure your Infopath Forms is able to run in the browser. Open the form in Design Mode, click Tools | Form Options then click  Compatibility on the left and click the checkbox that says "Design a form template that can be opened in a browser or Infopath" and do a verify. After that is done, republish your form.

So, now you have a form that can run in the browser. I'm not exactly sure what the 3rd party workflow software is that you're talking about, so I'm not exactly sure what all it can do. I'd suggest reading up on the Infopath Forms Services SDK (http://msdn.microsoft.com/en-us/library/ms772301.aspx) and seeing if something there turns on the lightbulb for you. My guess is that you may want to just pass a URL to open the form in the browser and then save it. That may be all you need to do.

The reason I suggest going down this path is that, while I'm sure there's some way to do it, I'm not sure there's a good way to kick-off the Infopath rule processing without having Infopath open.

2) Build an EXE that uses the Infopath control.
Not exactly sure what your 3rd party software is, but the key thing is that you're going to need to reference the DLL located at C:\Program Files\Microsoft Office\Office12\Microsoft.Office.Infopath.FormControl.dll. At that point, you can then write code to instantiate a form control which will then host the running infopath form. Doc'n on calling that is at C:\Program Files\Microsoft Office\Office12\Microsoft.Office.Infopath.FormControl.dll

If you're serious about Infopath development, there's a 1200-page book "Designing Forms for Microsoft Office InfoPath and Forms Services 2007" which goes through a coding example of this (I keep it on my safari.oreilly.com bookshelf for reference).

Anyways, the reason I suggest either of the above two methods is that I think you're going to have to have Infopath running for the rules to get picked up on the form. The main reason is that the .xml file that holds your Infopath data doesn't have the rules in it; it's just an xml file of the data that has a reference at the top of it to the .xsn that was used to create the form. So, now, that .xsn is really just a collection of files, most importantly there's manifest.xsf which at the bottom of it will have two sections describing your rules and validations that have been created. I think it would be an exercise in frustration and limitation to try and create something that opens the .xml, then the .xsn, the the .xsf, then iterates through the rules and tries to figure out the errors.

Good luck, hope that helps.
0
 
Clay FoxDirector of Business IntegrationCommented:
You can open, and submit forms via code.

Research some of the command line options but deffinetly you could automate this with windows script host.
I have used a vb routine to automatically open a form while passing in data from a db and then the submit emailled it to the user info passed in. I beleive you can accomplish what you need to automate.

www.infopathdev.com should help.
0
 
TicketKevAuthor Commented:
clayfox - Thanks for your reply.  I know I can automate opening and closing the form via code, but what I need is some way to open it, get the error count with data, and close it but WITHOUT actually opening and thus firing off the Infopath client.  I guess I"m looking for a way to tap into the XSN file without the overhead of running the Infopath client.  
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
TicketKevAuthor Commented:
clayfox - Another question for you:  In your vb routine to open and close the form, what type of volume did it handle?  Did you experience any issues?  If we can open and close Infopath several times in a minute without anything coming back to bite us, we would feel better about just going that route.  Thanks.
0
 
Clay FoxDirector of Business IntegrationCommented:
Your other option is to process the xml directly, replicate the logic from the form.

I had mine run once through about 1 thousand forms but did not monitor the performance.  I would think if you had the process run on submit that even with 2k users you are not going to have many simultaneous forms.
0
 
hstaples53Commented:
Soprry the documentation on creating a hosted FormControl in an EXE is at
http://msdn.microsoft.com/en-us/library/microsoft.office.infopath.formcontrol(VS.80).aspx 
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.