Solved

Accessing Infopath rules without opening Infopath form

Posted on 2008-09-30
6
1,041 Views
Last Modified: 2010-05-18
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.
0
Comment
Question by:TicketKev
  • 2
  • 2
  • 2
6 Comments
 
LVL 28

Expert Comment

by:clayfox
ID: 22607620
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
 

Author Comment

by:TicketKev
ID: 22607700
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
 

Author Comment

by:TicketKev
ID: 22607730
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 28

Expert Comment

by:clayfox
ID: 22611568
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
 
LVL 1

Accepted Solution

by:
hstaples53 earned 500 total points
ID: 22682533
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
 
LVL 1

Expert Comment

by:hstaples53
ID: 22682545
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

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

When installing SharePoint 2010 RTM I came across a strange error, I was getting timeouts during the installation. I searched the web and found the best solution to be found here (http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010genera…
I recently came across an issue with a MOSS 2007 deployment where access into some sub-sites were denied, even for the MOSS farm administrators. A bit of background to the setup of this MOSS farm; this was a three server setup, consisting of a fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now