.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

infopath submit with code, code wont run

Posted By:      Posted Date: October 13, 2010    Points: 0   Category :SharePoint

I have a infopath form, with some c# code.

when i test te form local it works.

so i have upload the form to the sharepoint and activate it.

when i test the form in a library the code wont work, i think the code wont be called.


i'm working localy, not on the sharepoint server.

how will my code get on the server or is this a manual interaction?

is there something i forget at the moment?

View Complete Post

More Related Resource Links

infopath submit with code


i have a document library where you can add several forms.

within this library i have a folder structure, when i want to add a new form, i will go to the a specific folder and i click on the new button and i select a form.

i want to use the submit button, but at this point i most insert a data connection with a specifiek url, but i can't know at the beginning in witch folder the user is working.

is it possible to use the submit button with code, so when i'm in a folder the document will be saved in this folder without any interaction ?

or is it possible to use a submit button with rules?



Cannot submit an infopath 2007 data source to sql database using managed code - C#.


Is this possible?  I can submit the data source just fine using custom action rules either from a submit button on the form or from the submit button from the tool bar.

But when I try to use C# nothing below works, Main Connection is my data source.  I get unhandled exception errors when I run the form in debug

AdoSubmitConnection sc = (AdoSubmitConnection)this.DataConnections["Main Connection"];

WebServiceConnection sc = (WebServiceConnection)this.DataConnections["Main Connection"];

FileSubmitConnection sc = (FileSubmitConnection)this.DataConnections["Main Connection"];

However I can send an email just fine using ;

EmailSubmitConnection sc = (EmailSubmitConnection)this.DataConnections["Email Connection"];


Any help would be greatly appreciated



Infopath form return XMl code during workflow task


1.     Review 7777.xml.

2.     Perform the specific activities required for this task.

Use the Edit this task button to mark the task as completed. (If you cannot update this task, you might not have access to it. Click here to request access.

Extracting Infopath form templates (with code behind) from a farm



I am in the middle of a migration of MOSS 2007 on server 2003 R2 to server 2008 r2, to be in the position to migrate to SP 2010. I am trying to extract form templates (with code-behind) from the old farm to the new farm. I did not set this farm up myself, so I would have copies of everything that was deployed to the farm, but now I don't. I have tried grabbing the .xsn from the Form Templates form library, and the form comes over, but no code behind, it says, The VB or C# project for this form template cannot be found. I have also tried extracting the solution files, and changing the file ext to .cab and opening the file up, only to find nothing very useful.

I need to extract and open the code up because I believe one of the forms that sends emails dynamically, is pointing to an old exchange server, because the emails are not getting through, and the exchange server was recently changed.

Any ideas would be much appreciated.


Infopath button click event in custom workflow code.


Hi All,

I have designed the infopath form(Init) and integrated with my state machine workflow. i want to access button click event (designed in Infopath form) in my workflow code.

Can you help me.




How to submit a form from code behind or something like that

Hi everyone,I dunno what would I do without the forum. I'm stucked again. Basically, what I am trying to figure out something like paypal where we call a specific URL from another web server and give them some information. Basically, I will have a URL like http://www.mysite.com/check_ur_balance.aspx?id=sth&blurblurblur where user call that URL and I query the information from the database and pass it back to the caller site.The flow is something like below:www.client.com  (hey give me this user balance) -> www.mysite.com (I query the user balance and send it back) -> www.client.comPlease help me out. Looking forward to receiving more input on this matter.

Infopath Changed Event code triggering in preview but not in web filler.

Hi there, I've written some code for a changed event hookup on a field in infopath 2010. The form is for submission to a sharepoint 2010 forms library. What the code does is fill in a specific value into a field depending on the selected value from a combo-box elsewhere on the form. When i preview this in Infopath 2010 it works perfectly but when i fill out the form through the web interface it simply does nothing. I've got another piece of code which executes on load and this works perfectly in both the preview and the web filler. What it does is just set the value of a field when the form loads. Here is the code, could someone tell me what i'm doing wrong? public void InternalStartup() { EventManager.XmlEvents["/my:myFields/my:service_level"].Changed += new XmlChangedEventHandler(service_level_Changed); EventManager.FormEvents.Loading += new LoadingEventHandler(FormEvents_Loading); } public void service_level_Changed(object sender, XmlEventArgs e) { // Write your code here to change the main data source. XPathNavigator xroot = MainDataSource.CreateNavigator(); XPathNavigator serviceLevel = xroot.SelectSingleNode("/my:myFields/my:service_level",NamespaceManager); XPathNavigator xest = xroot.SelectSingleNode("/my:myFields/my:est_cost", NamespaceManager); switch (serviceLevel.Value)

Best way to Deploy InfoPath form with connection information and managed code

Hi, Whats the best way to deploy an InfoPath form with connection information and managed code. Is there way I can create a deployment package for this? Thanks in advance, San

InfoPath repeating table Copy values from above row without Code

Hi, I have situation, where I want to copy the values from the above row to the newly created row in a Repeating table. Ex. I have a repeating table with 3 columns ID-Name-FileName. When I enter a data like 1-Customer1-File1.zip and hit "Insert new row", the new row should automatically populate the values of the above row. How can I do it without .Net code. Regards,

Accessing code in InfoPath 2003 forms from Visual Studio 2005

Can vbscript code contained in an InfoPath 2003 form be accessed from VS2005 on a machine running Office 2010? We are testing Office 2010 our our PC's and the custom task pane code that works just fine on PC's running Office/InfoPath 2007 does not run on the test PC's. I've been reading that the vbscript code in the form can't be edited directly when opening the form in InfoPath 2010, but that's not what I'm trying to do. I want to access the vbscript code through the .Extension property of the XDocument object from client side javascript code on an .aspx page like we have done for years. The existing code, which runs perfectly on PC's with Office/InfoPath 2007,  looks like this ... var xDoc = window.external.Window.XDocument; xDoc.Extension.UserLookupDone (userid); When run on PC's with Office/InfoPath 2010 the code throws error "Class doesn't support Automation". Are we trying something that is no longer possible? Any help is appreciated.

Can we managed code for a list using InfoPath forms?


Is possible to add manage code to Infopath LIST forms. We want to validate data that goes beyond what InfoPath can do out of  the box.

make a control required field using code in infopath


Hello guys,

How do i make a field required field using code. Specifically, how to make attachment control mandatory.

I know there is an option to select cannot be blank in properties but i want to do it conditionally.

Please help me.



Print option in InfoPath 2007 through Code

Hi All,

I am using the Info path 2007 web enabled. My requirements is to provide the Print option.

The Print option from standard tool bar i removed.

I need to print the current view form by using C# code.

I seached in net , i got help for Info Path 2003.I need help for Info path 2007 like PrintOut() in 2003.

Please help or suggest me to solve the requirements.

Get ListItemID in code behind an InfoPath Form


I have a few cases where I'm using an InfoPath form in a SharePoint list (for instance, as the default content type, so that clicking "New" in a Document Library opens an InfoPath form in the browser).

In the form's code-behind I would like to programmatically create a new item in another list, setting a Lookup Field's value there to the ListItemID of the item associated with the open InfoPath form. But I can't find any way to identify the ListItemID (or GUID) of the InfoPath form.

Does anyone know how to get the ListItemID of an InfoPath form in a SharePoint list, from within the InfoPath form's code-behind?


InternalStartup method erro when publish InfoPath form with custom code


Hi All,

I created a SharePoint Form Library, and added a button in the form. Then, by following the steps of adding custom code. I was trying to add codes to the button click event in VSTA. When I try to publish this form to my SharePoint library, I got an error message say:

"The form template has been published to the server but it can only be opened in InfoPath Filler.

There is an error in the InternalStartup method of form code.

There may be additional error detials in the Design Checker task pane."

However, I did not make any changes to the InternalStartup. and then I tried to create another SharePoint Form Library Form in InfoPath Designer, and just add click event, but did not input any code, I got the same error. So I believe this is caused by either environment or the configuration of SharePoint Server. Could anyone help me out? Thanks!

Get Infopath form URL from code C#



I need to include a hyperlink on the print view of an Infopath form. Now this is all good.

The problem is that the form does not close when submitted and then gets emailed to where it needs to go, so the url does not refresh. What I have done is to request the url:

XPathNavigator xnMyForm = this.CreateNavigator();
      XmlNamespaceManager ns = this.NamespaceManager;

      string strURL = HttpContext.Current.Request.Url.ToString();
      xnMyForm.SelectSingleNode("/my:myFields/my:secHidden/my:txtURL", ns).SetValue(strURL);

And then I set the hyperlink to the txtURL datasource.

So what happens is that when the email is sent without closing the form and reopening it and clicking on the hyperlink, I just get a new blank form. Only when I close the form and reopen it do I get the form that was submitted.

How can I get the datasource to refresh with the new url that is created for the specific saved form? Is there a place where it is saved? I have checked in the xml source of the saved form but I cannot see anything there..!

Infopath form timesheet question on rounding time and using code


We have a timesheet form that has 4 time fields:  Start Time, End Time, Actual Time and Billable Time. 

Our Start Time, End Time and Actual Time buttons and field calculations work just fine, but we want the 4th field to calculate the billable time by rounding UP to the quarter-hour.

For example:

Start Time - 9:00am

End Time - 11:20am

Actual Time -  2:20

Billable Time - 2:30 (or 2h30min)


I'm new to Infopath and not sure how we would accomplish this.  What type of code would I need and can I even use code on that Billable Time field to accomplish this?


Thanks for any help you can give me!


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend