OnSubmitRequest() and web service submission - InfoPath Dev
in

InfoPath Dev

OnSubmitRequest() and web service submission

Last post 11-07-2005 09:11 PM by vt_asparagus. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 11-07-2005 06:25 PM

    OnSubmitRequest() and web service submission

    I'm integrating my InfoPath form with a K2.net workflow and I'm having difficulty with the OnSubmitRequest() event handler.

    Prior to integration with K2.net, it doesn't matter if I set a button to a 'Submit' action, or to 'Rules and Custom Code' and call thisXDocument.Submit() within the button's event handler, either way OnSubmitRequest() is called.

    After integration, there doesn't appear to be any way in which I can get OnSubmitRequest() to be called. If I set my button to the 'Submit' action it calls the K2.net web service and the form is submitted without calling OnSubmitRequest(). If I set my button to 'Rules and Custom Code' then the event handler for the button is called, the form is submitted but again OnSubmitRequest() is never reached.

    I'm wondering if the behaviour described above is a peculiarity of K2.net or common for submission by web service? Has anyone used OnSubmitRequest() in conjunction with a web service submission process? Surely it's not uncommon...

    FYI OnSubmitRequest() is required to do some custom validation before the form is submitted - I guess I could move the code elsewhere but I'm hoping I don't have to.
  • 11-07-2005 06:58 PM In reply to

    Re: OnSubmitRequest() and web service submission

    Not sure if anyone else has used K2 extensively on this forum. Luckily I have.

    I found this to be an issue as well. It sounds like you have some of your own custom code, so K2 forced you down the path of using a custom task pane to submit. Correct?

    This is what we did. On the K2 server there is a directory called C:\Program Files\K2.net 2003\Bin\Temp\IPResourceFiles. In that directory there are the files that K2 shoves into InfoPath, specifically the k2 custom task pane (taskpane_new.htm). If you jump into the code, you will see there is a submit to thier webservice. What we did was place methods around that submit call that have to be implemented on the InfoPath form. We did something like:

    if (window.external.Window.XDocument.Extension.CanSubmit()) {
    window.external.Window.XDocument.Extension.BeforeSubmit();
    gobjXDocument.Submit();
    window.external.Window.XDocument.Extension.AfterSubmit();
    }

    Once you make this change, you will need to refresh your InfoPath form with the K2 process by right clicking the process. Now you will need to implement these methods on EVERY InfoPath form that is exported to that server.

    Now all you need to do is call your validation fuction inside of CanSubmit() inside of InfoPath.

    The nice thing about doing this is that all of your forms will have a consistent approach to handling the K2 submission. So if you have future forms that may not the same type of validation model, you can simply just return true and you are done.

    I did not use the OnSubmitRequest() but I think moving the code to this new method should do the trick. Hope this helps.

    Isn't K2 GREAT tool. I have loved working with it thus far.
    Jason
    http://www.k2distillery.com/
  • 11-07-2005 07:43 PM In reply to

    Re: OnSubmitRequest() and web service submission

    Thanks for your quick reply. Nice idea - although I'm not entirely sure if you're being sarcastic with the last comment on K2. ;)

    I'm not actually using the task pane, instead I'm using a button on my form that when set to 'Submit' action works fine for submitting to K2 - as long as you don't want OnSubmitRequest() to run.

    Since posting, I've found that if I use any web service to submit my form then OnSubmitRequest() isn't called. Either it's only used for code-based submission or I've stuffed up somewhere.

    Anyway - I've tried the approach of having an event handler for my button that calls ValidateForm(), basically the same content as my original OnSubmitRequest() but called explicitly, which takes care of any custom validation. If that succeeds I call the thisXDocument.Submit() method and catch any errors that may be thrown.

    This seems to work fine, although I reserve the right to post again on this topic when I find I've missed something. :o)
  • 11-07-2005 07:56 PM In reply to

    Re: OnSubmitRequest() and web service submission

    I was not intending to be sarcastic. I edited my comment :-) I have so many positive things to say about the software. K2 provides a generic framework with simple easy integration with BizTalk, InfoPath, ASP.net, SharePoint ... and soon WinForms. I did a large gov't contract for 3 years writing a custom workflow application in C# and it took forever. Wish we had this product at the time.

    No problem. I live to serve and to be a "workflow junkie"...
    Jason
    http://www.k2distillery.com/
  • 11-07-2005 08:15 PM In reply to

    Re: OnSubmitRequest() and web service submission

    Thanks again, I appreciate your help.

    K2 is good - although it'd be great if they'd integrate more fully with Visual Studio, the IDE is a little basic for code dev. But I'm picky. :)
  • 11-07-2005 09:11 PM In reply to

    Re: OnSubmitRequest() and web service submission

    I have heard from sources that the next version will be integrated in VS! I agree that the code editor can use improvement but looks like they are on the way to fix that.
    Jason
    http://www.k2distillery.com/
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.