Skip to main content
I've read other threads concerning this issue, and while they helped me understand what exactly is going on, they don't seem to solve my problem ...

I've created an Infopath form, and I've chosen not to have the K2 Task Pane. I would like to remove the other menu submit button that K2 automatically adds, mostly because of some code that I need to run before a form is submitted. I would also like to avoid the user pressing submit by accident (instead of maybe save). The form requires quite a bit of time to fill out, so the user will be periodically saving the form and return to it from time to time to complete. A custom submit button would appear on the form once certain conditions are met and the user changes the form's status.

I've tried the solution proposed in another thread, about re-publishing the template, but it doesn't work for me. I'm publishing the form to a Sharepoint list, and if I open up a form, save it locally, enter design mode, uncheck the "Enable the Submit menu item on the File menu" and re-publish the template, I get the following error when I try to open up the form again from Sharepoint:

x-soln://9453a9b9aac8494e/TrustRecs.xsd#/schema/import[1]
System error: -2147287038.

I've tried it a bunch of different ways and I always get the same error. Seems to be some kind of installation error?

I've also noticed a Data Field called "K2DisableSubmitButton" that's included in K2 Infopath processes. Unfortunately this field is always set to false when the Infopath process wizard is run (even if I set it to true before running the wizard). Would I have to create a custom process template to set this field to true? I'm not sure if it would remove the submit button anyways.

Any help would be greatly appreciated.
Hi Phillipe,

if you want to disable the Submit button in the Toolbar of your Infopath document you can use this piece of C# code (e.g. in your OnLoad Event):

 {1,33769}; //33769 is the ID# of the Submit Button

CommandBarControl commandBarsFindControl = (CommandBarControl)commandBars.InvokeByName(
"FindControl", // property
MethodFlags,
args2, // arguments
null); // Culture

commandBarsFindControl.Enabled = false;


If you are talking about the K2.net Taskpane Submit button add a Button to you Infopath form. On the Button properties in the General Tab choose Submit as Action. Then click "Define Action Parameters" and check the Edit Form code. Then add thisXDocument.Submit(); in your OnSubmitRequest Method. That is already it now when running the Infopath Process Wizard in K2.net Studio just uncheck the Display Taskpane with Submit Button Check Box and that does it.

Hope I could help you.
Thanks nukkumatti! Only problem is that my form isn't fully trusted (which you need to access the CommandBarControl class) and I'd like to keep it at the Domain security level. I'd still like to find a solution where I don't have to change the security level, but at least I have this option as backup. Thanks again.
Ok, I was able to get around the system error, so now the re-publishing method works for me. I'll explain the reason for the system error, although I think its pretty rare. Here's a summary:

The Infopath form I've created is based on a schema that I built outside Infopath using Visual Studio. So basically there are no "my:" elements or a myschema.xsd in my original solution that I publish to Sharepoint, although I do include a "xs:any" element in the schema (so that K2 can later add its custom elements). So when I run the infopath process wizard in K2 Studio, K2 modifies the .xsn file by adding its elements to the schema, as well as a myschema.xsd file and a reference to it in the manifest file.

To do the re-publish method to remove the submit button, I open the form from Sharepoint after the K2 wizard is done, enter design mode in Infopath, uncheck the submit button option, and re-save it. If I try to open the form again, I get the system error.

It ends up that Infopath was removing the myschema.xsd file and any references to it in the manifest file when I tried to re-publish the form. In the end, all I had to do was add one "my:" element to my data source using Infopath and now the re-publishing works fine since the myschema.xsd and the reference to it in the manifest file are always there.

Reply